So far this is what I have,I already have a Configuration file but I dont know whats wrong
game.Players.ChildAdded:connect(function(player) player.Chatted:connect(function(chat) if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then if string.lower(chat) == "sf" then if not game.Workspace:FindFirstChild("Thing") then game.Lighting.Thing:Clone().Parent = game.Workspace end elseif string.lower(chat) == "close sf" then if game.Workspace:FindFirstChild("Thing") then game.Workspace.Thing:Remove() end end end end) end)
First off, you should use the PlayerAdded
event instead of ChildAdded
. Also, it would be better to check if they're and admin once the join the game, instead of every time they chat.
game.Players.PlayerAdded:connect(function(plr) if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then --I assume config is defined somewhere? plr.Chatted:connect(function(msg)
Don't forget to rearrange you ends after making these changes!