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

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

wait()
	script.Parent.Text = "Gems: " .. game.Players.LocalPlayer.Gems.Value

1 comment

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

3 answers

✓ Accepted answer

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

2 comments

0

I will try that

0

thx

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

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)

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