In Roblox Studio, the local player’s UserId starts at 0 before changing to the correct value in runtime.
This bug was experienced in Roblox Studio Version 0.365.1.265265
running on macOS Mojave 10.14.1
.
Repro steps
This can be seen with the following code placed into a LocalScript
in StarterPlayerScripts
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
print("LocalPlayer UserId is ", LocalPlayer.UserId)
LocalPlayer:GetPropertyChangedSignal("UserId"):connect(function()
print("LocalPlayer UserId now ", LocalPlayer.UserId)
end)
When run in Test Solo the output is (correctly) as follows:
LocalPlayer UserId is 123456
When run in Test Server + Player, the output is (incorrectly) as follows:
LocalPlayer UserId is 0
LocalPlayer UserId is now -1
Expected Behaviour
LocalPlayer.UserId
at the top of a LocalScript
in Test Server + Player returns the correct UserId
(ie -N)
Actual Behaviour
LocalPlayer.UserId
at the top of a LocalScript
in Test Server + Player returns 0 before changing to the correct UserId
after an arbitrary amount of time (0.0067 seconds in my test)