I made a script to make a GUI make the time change by one second. Time changes from a Script, not a LocalScript. I tested it, but the change takes effect on the "Timer" Value
. It won't take effect on the GUI. Any solutions?
Snippet:
local Infomation = script.Parent:WaitForChild("Infomation") local replicated = game:GetService("ReplicatedStorage") Infomation.Text = replicated.Timer.Value
Here's what you need to do:
local Infomation = script.Parent:WaitForChild("Infomation") local Timer = game.ReplicatedStorage.Timer Timer.Changed:connect(function() Infomation.Text = Timer.Value end
Here's a quick rundown of what changed.
First, I changed this top bit
local Infomation = script.Parent:WaitForChild("Infomation") local replicated = game:GetService("ReplicatedStorage")
To this
local Infomation = script.Parent:WaitForChild("Infomation") local Timer = game.ReplicatedStorage.Timer
You don't really need a variable that represents ReplicatedStorage, just a variable for the Timer itself.
Next, I changed this:
Infomation.Text = Timer.Value
to this:
Timer.Changed:connect(function() Infomation.Text = Timer.Value end
The issue before is that you only set the TextLabel's Text
to the Timer's Value
once. Therefore, it won't update. When you set something to the value of the Timer, it doesn't link them together in some sort of an automatic connection. Instead, what happens, is the Information's Text
gets changed to the current Value
of Timer.
What the new solution does is update Information's Text
every time Timer
's Changed event fires (which would be every time a property of Timer
changes).
I hope this helped you. Good luck!