Why does name doesn't work on local player? (SOLVED!!)
Asked by
4 years ago Edited 4 years ago
So, basically I am trying to make a admin command but whenever I say "game.Players.LocalPlayer.Name" it always get a error called "attemp to index nil with "Name""
Here is the whole code:
03 | local admins = { "scooter369" , "airstrike0103" } |
05 | game.Players.PlayerAdded:Connect( function (player) |
06 | player.Chatted:Connect( function (message) |
08 | local messagesplit = message:split( " " ) |
09 | local splittoo = messagesplit [ 1 ] :split( "/" ) |
10 | splittoo [ 2 ] = string.lower(splittoo [ 2 ] ) |
13 | if splittoo [ 2 ] = = "kick" then |
14 | for i, v in pairs (admins) do |
15 | if game.Players.LocalPlayer.Name = = v then |
18 | print ( "player not admin" ) |
21 | targettokick = messagesplit [ 2 ] |
22 | if game.Players:FindFirstChild(targettokick) then |
23 | game.Players [ targettokick ] :Kick( "You have been kicked from the game.." ) |
If you want to get in the line where I get the error, Go to line 15..
help pls