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

Leaderstats GUI not updating with the script?

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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

0
Thanks! That solved it! Raven_Caedes 95 — 8y
0
Anytime! docrobloxman52 407 — 8y
Ad

Answer this question