Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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:

01local prefix = "/"
02local targettokick
03local admins = {"scooter369","airstrike0103"}
04 
05game.Players.PlayerAdded:Connect(function(player)
06    player.Chatted:Connect(function(message)
07 
08        local messagesplit = message:split(" ")
09        local splittoo = messagesplit[1]:split("/")
10        splittoo[2] = string.lower(splittoo[2])
11 
12 
13        if splittoo[2] == "kick" then
14            for i, v in pairs(admins) do
15                if game.Players.LocalPlayer.Name == v then
View all 27 lines...

If you want to get in the line where I get the error, Go to line 15..

help pls

0
Is it in a local script spunkworks 110 — 4y
0
instead of game.Players.LocalPlayer == v try player.Name == v, since you've already got the player from the playeradded event Warphi 51 — 4y
0
its not in local script InspireWithFun 9 — 4y
0
Thank you Warphi. InspireWithFun 9 — 4y
View all comments (3 more)
0
Nope, Now it always says that player is not an admin. InspireWithFun 9 — 4y
0
I messed up the script and it works now, thank you all anyways, InspireWithFun 9 — 4y
0
Is it just me or do I see a extra 'end)' in the code? Prime_Jayden 11 — 4y

Answer this question