Hello! I am working on a script currently and i am having a error which i tried to fix but I cant. Basicly this Script is in StarterCharacterScripts and its supposed to get the Players ID its parented to and put the ID into the Stringvalue I made. It isnt working and its giving me "nil index" errors, is there a way to fix this? heres my script I used
1 | ID = game.Players.LocalPlayer.UserId |
2 |
3 | script.Parent.Value = ID |
Replace your code with this:
1 | script.Parent.Value = tostring (game.Players.LocalPlayer.UserId) |
In your code, it didn't detect players and returned a "nil index" error because you tried to put a number value inside a string value without transforming it into a string, this script here gets the number value of the LocalPlayer.UserId
and makes it a string.