generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: certain part of admin script not working?

Previous Thread :: Next Thread 
tigerr666 is not online. tigerr666
Joined: 13 Aug 2009
Total Posts: 1665
13 Aug 2012 11:36 AM
Works:

vip = game.Players.tigerr666

function onChatted(msg)
if msg == "kick all" then
p = game.Players:GetChildren()
for i = 1, #p do
p[i]:remove()
end
end



Doesn't work: function onChatted(msg)
if msg == "give me fire" then
Instance.new("Fire").Parent = game.Workspace.tigerr666.Head
end
end

vip.Chatted:connect(onChatted) anyone help?
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
13 Aug 2012 11:37 AM
You need to put both commands in the same function

function onChatted(msg)
if msg == "kick all" then
p = game.Players:GetChildren()
for i = 1, #p do
p[i]:Destroy()
end
end
if msg == "give me fire" then
Instance.new("Fire").Parent = game.Workspace.tigerr666.Head
end
end
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
13 Aug 2012 11:38 AM
    local admins={"nate890"}
    
    local commands={
        admin=function(msg)
            local players=getPlayers(msg)
            for i,c in pairs(players) do
                table.insert(admins,c.Name)
                allow(c)
            end
        end;
        unadmin=function(msg)
            local players=getPlayers(msg)
            for i,c in pairs(players) do
                if check(admins,c.Name) then
                    table.remove(admins,check(admins,c.Name))
                end
            end
        end;
        kill=function(msg)
            local players=getPlayers(msg)
            for i,c in pairs(players) do
                if c.Character then
                    c.Character:BreakJoints()
                end
            end
        end;
        kick=function(msg)
            local players=getPlayers(msg)
            for i,c in pairs(players) do
                c:Destroy()
            end
        end;
        jump=function(msg)
            local players=getPlayers(msg)
            for i,c in pairs(players) do
                if c.Character and c.Character:FindFirstChild("Humanoid") then
                    c.Character.Humanoid.Jump=true
                end
            end
        end;
    }

    function check(t,v)
        for i,c in pairs(t) do
            if c==v or v==i then
                return i
            end
        end
    end

    function getCommand(msg)
        if string.match(msg,("%p-/-%w+")) then
            return string.match(msg,("%p-/-%w+"))
        end
    end
    
    function getPlayers(msg)
        local players={}
        for i in string.gmatch(";"..msg:sub(#getCommand(msg)+2,#msg),(";%w+")) do
            for _,p in pairs(game.Players:GetPlayers()) do
                if p.Name:sub(1,#i:sub(2,#i)):lower()==i:sub(2,#i):lower() then
                    table.insert(players,p)
                    break
                end
            end
        end
        return players
    end
    
    function allow(plr)
        plr.Chatted:connect(function(msg)
            if check(admins,plr.Name) then
                local command=getCommand(msg)
                if command and check(commands,getCommand(msg):lower()) then
                    commands[command:lower()](msg)
                end
            end
        end)
    end
    
    game.Players.PlayerAdded:connect(function(plr)
        if check(admins,plr.Name) then
            allow(plr)
        end
    end)
Report Abuse
tigerr666 is not online. tigerr666
Joined: 13 Aug 2009
Total Posts: 1665
13 Aug 2012 11:38 AM
Did that. Only the first command end up working.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
13 Aug 2012 11:38 AM
^
or this


Btw nate, how tab? D: D:
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
13 Aug 2012 11:38 AM
You have two functions and in your connection line it doesn't know which onChatted function to pick.


Why not put your second script inside your first?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
13 Aug 2012 11:39 AM
You can tab by using alt + 255, or you can get nxtboy's Forum Enhancer extension from the chrome store (which is what I'm using)
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
13 Aug 2012 11:40 AM
   orly?
I use firefox :P
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
13 Aug 2012 11:42 AM
Then you're gun' have to stick with alt + 255
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
13 Aug 2012 11:43 AM
Roblox logic: Let's make 2 forums about scripting! Let's not include any < code > tags!
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
13 Aug 2012 11:45 AM
Haha... I think roblox's forum can be a ton better. I forum on multiple forums, all of which allow images, bb code and code tags.
Report Abuse
tigerr666 is not online. tigerr666
Joined: 13 Aug 2009
Total Posts: 1665
13 Aug 2012 11:45 AM
I think i'll just use findFirstChild...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image