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

Why does the change in a Value doesn't copy the change into a GUI text?

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

1 comment

0

Is this the full code? I don't think this is enough for SH to help you with.

1 answer

✓ Accepted answer

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!

2 comments

0

I think that you need a Variable for replicated service.

0

Nope.

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