This is my SIMPLE admin scripts, but I can't even get 2 commands to work together! This is what I have so far!
Permission = {"MasterAzzer"} game.Players.ChildAdded:connect(function(Player) Player.Chatted:connect(function(msg,speaker) for i = 1, #Permission do if string.lower(msg) == "fire" and Player.Name == Permission[i] then plr = Player.Character f = Instance.new("Fire") f.Parent = plr.Torso end if string.lower(msg) == "unfire" and Player.Name == Permission[i] then plr = Player.Character f = plr.Torso:FindFirstChild() if f ~= nil then f:remove() end end end end) end)
Several problems here.
First, you should do the PlayerAdded
event instead of ChildAdded
.
Second, I'm not even sure that Chatted
events HAVE a speaker parameter, but even if they do, you never used it and it's easier to just use player
of the PlayerAdded
event.
Third, you should should check if the new player that joined the game is an admin, and THEN connect the chatted event, instead of connecting the event to every player and checking if they're an admin after they chat.
Fourth, it would be better to put the for
loop in an extra function. Although this is not necessary, it is cleaner.
Fifth, you should use 1 if
statement and an elseif
instead of two if
statements.
Sixth, on line 14 you are basically looking for nothing. FindFirstChild()
takes one argument, which is the child you are trying to find.
Here's my edited version of your script.
Permission = {"MasterAzzer"} function isAdmin(name) for i,v in pairs(Permission) do if v:lower() == name:lower() then return true --Returning something stops the execution of a function and basically turns it into a variable of sorts. end end return false end game.Players.PlayerAdded:connect(function(plr) if isAdmin(plr.Name) == true then --If it returned true plr.Chatted:connect(function(msg) if msg:lower() == "fire" then local f = Instance.new("Fire",plr.Character.Torso) elseif msg:lower() == "unfire" then local f = plr.Character.Torso:FindFirstChild("Fire") if f then f:Destroy() --Remove() is deprecated. Better to use Destroy(). end end end) end end)