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

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

Asked by 5 years ago

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..

0
call the function and pass their user id EpicMetatableMoment 1444 — 5y

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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.

0
Thanks :) User#23357 0 — 5y
Ad

Answer this question