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

How do you change a numbervalue's value to local player's Id?

I'm not sure why this doesn't work. I'm new to scripting.

local Players = game:GetService('Players')
local function getPlayerByUserId(userId)
	script.Parent.Configuration.userId = userId
end

Any help will be appreciated..

1 comment

0

call the function and pass their user id

1 answer

✓ Accepted answer

You aren't referencing to the specified Player you'd like to have replace your NumberValue with their UserId. You should do so. You haven't called the function either.

local Player = game:GetService('Players').LocalPlayer --// Returns *your* Player
local function SetToPlayerId(UserId) --// I believe you understand arguments and parameter already?
    script.Parent.Configuration.userId = UserId
end
SetToPlayerId(Player.UserId)

This should work properly, this should be a LocalScript inside of StarterPlayerScripts.

1 comment

0

Thanks :)

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