Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

2 comments

0

Not enough information to give an answer (give us the script)

0

done

1 answer

✓ Accepted answer

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.

1 comment

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.