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

Script doesnt detect Players ID, what to do?

Asked by 2 years ago

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
0
check if it's a LocalScript. if it is then put the localscript in starterplayerscripts MarkedTomato 810 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

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.

Ad

Answer this question