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

Why are the text labels and buttons not changing text?

So basically there are two values (1 is a String Value and 1 is a Number Value. So this script will change the values of the 2 values.

wait(1)
	Textvalue.Value = "Intermission!"
	
	timevalue.Value = 30
	repeat
		timevalue.Value = timevalue.Value - 1
		wait(1)
	until timevalue.Value == 0

Then a local script will change the button text when changes happen to the string value.

local status = game:GetService("ReplicatedStorage").Text

status.Changed:Connect(function()
	script.Parent.Text = status.Value
end)

Then a local script will change the Text text when changes happen to the number value.

local status = game:GetService("ReplicatedStorage").Time

status.Changed:Connect(function()
	script.Parent.Text = status.Value
end)

Anyone know why this isn't working? It works in STUDIO, but not in GAME also!

6 comments

0

Isn’t it a good thing it works in game? Everyone complains that "it works in studio, not in game!" You’re lucky.

0

U 2 cool to use a for loop?

0

I meant it worked in studio and not game...

0

I meant it worked in studio and not game...

0

Ye thats a filtering enabled problem.

0

Is the top paragraph of code in a srv script or local?

1 answer

The reason this is not working is because you're changing a ValueBase object. The better solution to this issue is to use RemoteEvents to tell clients what the text needs to be changed to.

Additionally, do not use repeat loops for a countdown script, use a for i loop.

wait(1)
    Textvalue:FireAllClients("Intermission!") -- define

    for i = 30,1,-1 do
        timevalue:FireAllClients(i) -- define
        wait(1)
    do
Textvalue.OnClientEvent:Connect(function(v) -- define textvalue
    script.Parent.Text = v
end)
timevalue.OnClientEvent:Connect(function(v) -- define timevalue
    script.Parent.Text = v
end)

Everywhere I said to define you should create a RemoteEvent in ReplicatedStorage and create a variable referencing to it. Please note that there will be a tiny delay as the information is being sent from the server on Roblox's end to every player's computer.

Hope this helps, make sure to accept the answer if it did!

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