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

How to make a number value rise and output as a text label?

So, I'm trying to make a points GUI. So, every second, you get 1 point. This script is a local script within the text label that displays the points. The number value is within the same parent as the script. Anyone able to help?

script.Parent.Text = script.Parent.Value.Value

while true do
	script.Parent.Value.Value = script.Parent.Value.Value + 1
	wait(1)
end

1 answer

✓ Accepted answer

Anything inside a LocalScript is ONLY run on the client. This means that the changes will not replicate to every other player in the game. Since you are adding 1 point every second to the player through a LocalScript, you aren't actually giving them any points.

What you need to do is set-up a leaderboards script in ServerScriptService and run your loop on that value instead.

To show the user how many points they have on a GUI, you will want to put a LocalScript inside the TextLabel and get it to update the Text whenever the points increase.

local Player = game:GetService("Players").LocalPlayer -- Get the local player
local points = Player.leaderstats.Points -- Get the points
local PointsText = script.Parent

Points:GetPropertyChangedSignal("Value"):Connect(function() -- Whenever the points value changes then run the code
	PointsText.Text = points.Value
end)

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