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

Script doesnt detect Players ID, what to do?

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

ID = game.Players.LocalPlayer.UserId

script.Parent.Value = ID

1 comment

0

check if it's a LocalScript. if it is then put the localscript in starterplayerscripts

1 answer

✓ Accepted answer

Replace your code with this:

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.

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