So far this is what I have,I already have a Configuration file but I dont know whats wrong
01 | game.Players.ChildAdded:connect( function (player) |
02 | player.Chatted:connect( function (chat) |
03 | if player:GetRankInGroup(config.GroupId.Value) > = config.RankId.Value then |
04 | if string.lower(chat) = = "sf" then |
05 | if not game.Workspace:FindFirstChild( "Thing" ) then |
06 | game.Lighting.Thing:Clone().Parent = game.Workspace |
07 | end |
08 | elseif string.lower(chat) = = "close sf" then |
09 | if game.Workspace:FindFirstChild( "Thing" ) then |
10 | game.Workspace.Thing:Remove() |
11 | end |
12 | end |
13 | end |
14 | end ) |
15 | 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.
1 | game.Players.PlayerAdded:connect( function (plr) |
2 | if player:GetRankInGroup(config.GroupId.Value) > = config.RankId.Value then --I assume config is defined somewhere? |
3 | plr.Chatted:connect( function (msg) |
Don't forget to rearrange you ends after making these changes!