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

Leaderstats GUI not updating with the script?

Hi. I'm trying to make this GUI update its text with the current amount of points from the leaderstats. However, it stays at 200 (the set amount of points) and does not update with the script.

local currentPoints = script.Parent
local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
if leaderstats then
--Reflect the current amount of points inside the leaderstats
	currentPoints.Text = "$: " ..leaderstats.Points.Value
end

1 answer

✓ Accepted answer

Hi, I can help you. First you want to define the player:

plr = game.Players.LocalPlayer

Second you want to repeat a wait until leaderstats is loaded like:

repeat wait() until plr:WaitForChild("leaderstats")

Third you want to have a while loop so that it updates every second

while true do
wait()
script.Parent.Text = "$: " ..plr.leaderstats.Points.Value
end

The whole script:

plr = game.Players.LocalPlayer

repeat wait() until plr:WaitForChild("leaderstats")

while true do
wait()
script.Parent.Text = "$: "..plr.leaderstats.Points.Value
end

Remember this needs to be in a local script

2 comments

0

Thanks! That solved it!

0

Anytime!

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