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

I have a GUI that displays the Gems of the player. but it doesnt update. help?

Asked by 4 years ago
wait()
    script.Parent.Text = "Gems: " .. game.Players.LocalPlayer.Gems.Value

0
When the value updates the GUI doesnt. when i try to run a while loop it crashes the game cause you cant use a while loop in starter gui folder itshydro7 1 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

ok, this is how I did points for my game: you have to do this: also, make sure that "Gems" is in starter player then


while true do: script.Parent.Text - "Gems: " .. game.Players.LocalPlayer.Gems.Value wait() -- try adding a wait, that might clear it up end
0
I will try that itshydro7 1 — 4y
0
thx marine5575 359 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I think you would be better off just checking whenever the value changes, perhaps like this

game.Players.LocalPlayer.Gems.Changed:Connect(function()
    script.Parent.Text = "Gems: " .. game.Players.LocalPlayer.Gems.Value
end)

I'm on mobile so it might not be exactly right but hopefully you get the idea

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The reason it crashes when you use a while loop is because you need a wait() when using it.

while true do
    wait()
    script.Parent.Text = "Gems: "..game.Players.LocalPlayer.Gems.Value
end

Though I'd just detect whenever the value is changed then change the text.

game.Players.LocalPlayer.Gems:GetPropertyChangedSignal("Value"):Connect(function() -- Or, if you wanted to, you could just do the .Changed event.
    script.Parent.Text = "Gems: "..game.Players.LocalPlayer.Gems.Value
end)

Answer this question