So i have a leaderboard in my game. In studio it works, but in-game it only works with my main account. When i change accounts it doesnt work for some weird reason.
Main account:
When the game starts i wait 10 second and then iterate through the ordered datastore and set the values on the leaderboard but the only thing that appears on the tester account is the template frame but the leaderboard is not showing. Why is this happening?
For the record, Players:GetPlayerByUserId(userId) accepts a number as an argument and returns a Player instance that corresponds to that user ID if they are in the game. You’re probably looking for
local userExists = true --whether this UserId was terminated or is invalid
userExists, template.User.Text = pcall(Plrs.GetNameFromUserIdAsync, Plrs, tonumber(entry.key))
if not userExists then
-- etc.
end
but this is just my guess at first glance. At the very least, your error message means that the player with the given UserId wasn’t in the game.