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

Why will the GUI not update?

Asked by 7 years ago

Hello! I'm having difficult with my leaderstats display GUI not wanting to update properly. Player generates in lobby, teleports to map, defeats opponents and money/exp/level increases on the leaderstats display in the upper right, and on my GUI, I have a separate GUI for each value. But once the round ends and the player is sent back to the lobby, the leaderstats in the GUI vanishes. (They still display correctly in the upper right corner.) When the player is teleported to the next map for the next round, the GUI will not update until the player earns more points/exp/level up. I want the GUI to remain up to date in the lobby too. :/ Any thoughts?

I have a Screen GUI, with a Text Box inserted and this local script inside the Text Box:

game.Players.LocalPlayer.leaderstats.Level.Changed:connect(function(newValue)
script.Parent.Text = "Level: ".. game.Players.LocalPlayer.leaderstats.Level.Value
end)

With "Level" replaced with "Points" and "EXP" for the other two leaderstat displays.

1
If they player isn't gaining Points, Levels, or EXP in the Lobby, the GUIs won't update because they are listening for the Changed event. This event only fires whenever the value is changed, like when a player gains EXP. You can have it set to a loop in the lobby if you'd like it to update there as well, although you may encounter a small amount of lag if you loop too quickly. OniiCh_n 410 — 7y
0
Excellent! A loop did the trick! Thank you much! :) local plr = game.Players.LocalPlayer local level = plr.leaderstats.Level while true do wait() script.Parent.Text = "Level: ".. level.Value end Never2Humble 90 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Answer was discovered with the suggestion by yanderbae

local plr = game.Players.LocalPlayer
local level = plr.leaderstats.Level
while true do
    wait()
    script.Parent.Text = "Level: ".. level.Value
end
Ad

Answer this question