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

Field Index LocalPlayer a Nil Value?????????

Asked by 6 years ago
Edited 6 years ago

something like that buts is RED ERROR i cant stop it its ruining me help if u care

i made a wait but that doesnt work :(

wait(5)

game.Players.LocalPlayer.Chatted:Connect(function(msg, recipient)

local ID = game.ReplicatedStorage.ID:Clone()

if msg == string.lower(":give id") or string.upper(":GIVE ID") then

if recipient then ID.Parent = recipient.Backpack else

ID.Parent = game.Players.LocalPlayer.Backpack

end

end

end)

0
Not enough information to give an answer (give us the script) User#20388 0 — 6y
0
done AdventurousHeight 5 — 6y

1 answer

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

game.Players.LocalPlayer is only available through LocalScript objects. Consider using the game.Players.PlayerAdded event, doing this server-side, and calling Player:WaitForChild("Backpack") to get the backpack.

Additionally, just check if the lower form of a message is equal to ":give id", rather than two comparisons, though I recommend using string patterns to split the message into arguments as I did in my older answer, as it's a far more extensible solution.

0
thanks AdventurousHeight 5 — 6y
Ad

Answer this question