Well, I’m not sure if this is the right topic to ask for help as I’m new to this site, but I have a problem with the script below. Every time a player joins the game, the text stays written as ‘Locked,’ even though the player has the amount of ‘Wins’ or even more. The text only shows the correct name after the player resets. Could someone please explain how to solve this issue? And look, I’ve tried several ways to solve it, but I couldn’t.
local uiu = script.Parent["UIU"]
local plr = game.Players.LocalPlayer
-- Localize o jogador
local player = game.Players.LocalPlayer
if player.leaderstats.Win.Value >15 then
uiu.Text = ""..uiu.Name
else
uiu.Text = "Locked"
end
Im pretty sure its because that script is running before your player’s data is fully loaded, You can just wait until the “player.leaderstats.Win.Value” Has changed, Example:
local uiu = script.Parent["UIU"]
local plr = game.Players.LocalPlayer
-- Localize o jogador
local player = game.Players.LocalPlayer
player:WaitForChild("leaderstats"):FindFirstChild("Win").Changed:Connect(function()
if player.leaderstats.Win.Value >15 then
uiu.Text = ""..uiu.Name
else
uiu.Text = "Locked"
end
end)
Note that this is example code, and shouldnt be copied and pasted, im simply giving what i think could work.
Thank you so much! You really helped me out with my problem. I don’t know much about programming, but I appreciate it a lot. I’m trying to learn, and I already know some things, but this was new to me.