Whoever is an admin and if they say "Kick all players" then it should kick all players, it does not work. :(
Admins = {"PreyStar"} --Only person that could say remove and does the command game.Players.PlayerAdded:connect(function(Player) Player.Chatted:connect(function(Msg, Person) if Person == (Admins[1]) then print 'Worked?' --Does not print!!!! if Msg == "Kick all players" then for i,v in pairs (game.Players:GetChildren()) do v:Kick() --I wanna kick the players if an admin says the msg. end end end end) end)
In line 5 of this code block, Person
should be Person.Name
since you're identifying a string value. Also, I would personally recommend that you connect the listening event AFTER the if statement because you don't need the event to fire every time a non-admin chats.
Admins = {PreyStar = true, Player1 = true} --Only people that can use commands. game.Players.PlayerAdded:connect(function(Player) if Admins[Player.Name] then Player.Chatted:connect(function(Msg, Person) print 'Worked?' if string.lower(Msg) == "kick all players" then for i,v in pairs (game.Players:GetChildren()) do v:Kick() -- Kick the players if an admin says the msg, including myself. end end end) end end)