Game Status Text Label Not Updating When Changed

  1. What I want to achieve?

I want to make a system that text in a text label changes when the core gameplay script changes a value in replicated storage.
2. Here is my setup
asdfaiofjasoijfasojfasfioasjfpioajaoisjfiasjfiajsdiasjfpajaiopfjajpdfasoifjasio

  1. What solutions have you tried so far?

I looked on the dev hub and posted another forum post asking how to see what event happens when the value is changed.

  1. Here is all the code I have for what I am trying to do

Core gameplay script

local status = game:WaitForChild("ReplicatedStorage").statusText
local statusText = status.value
wait(#game.Players:GetPlayers()>=1)
for number = 15,0,-1 do 
	wait(1)
	print("Intermission: " .. number)
	statusText = "Intermission" .. number
end
statusText = "Teleporting Players"
a = game:GetService("Players"):GetPlayers()
for _, v in ipairs(a) do
	v.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.teleblock.CFrame.X,5,workspace.teleblock.CFrame.Z)
end
statusText = "Teleporting Complete"
wait(2)
statusText = "Game Starting"

Updater local script

local status = game:WaitForChild("ReplicatedStorage").statusText.Value

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

this line creates a new variable statusText and populates it with the value stored at status.value. statusText is not a reference to status.value; just a copy of whatever string happened to be stored there at the time.

As a result; these updates to statusText don’t change the value at status.value

Alright I changed line 2 but it still doesn’t change the text. I’m going to check rn to see if it is the value that isn’t updating or the local script.

local status = game:WaitForChild("ReplicatedStorage").statusText
local statusText = game:WaitForChild("ReplicatedStorage").statusText.value
wait(#game.Players:GetPlayers()>=1)
for number = 15,0,-1 do 
	wait(1)
	print("Intermission: " .. number)
	statusText = "Intermission" .. number
end
statusText = "Teleporting Players"
a = game:GetService("Players"):GetPlayers()
for _, v in ipairs(a) do
	v.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.teleblock.CFrame.X,5,workspace.teleblock.CFrame.Z)
end
statusText = "Teleporting Complete"
wait(2)
statusText = "Game Starting"

it doesn’t update value. So I’m not sure what to do.

You didn’t change the logical flow at all. You’re still making the statusText variable be a copy of what was held in game:WaitForChild("ReplicatedStorage").statusText.value

updating that statusText variable later does not update game:WaitForChild("ReplicatedStorage").statusText.value

You need to update the instance it’s self

-- now statusText is a reference pointing at the StringValue instance
local statusText = game:WaitForChild("ReplicatedStorage").statusText

statusText.Value = "Intermission" .. number -- we update that StringValue by updating it's Value property

statusText.Value  = "Teleporting Complete" -- and again
statusText.Value = "Game Starting" -- you get the idea

I even changed “.value” to “.Value” which is what it was called in the value thing in rs

local a = game:WaitForChild("ReplicatedStorage").statusText.Value

print(a)
print(game:WaitForChild("ReplicatedStorage").statusText.Value)
-- they print the same string

a = 'not status text no moe' -- update a

-- print them both again
print(a)
print(game:WaitForChild("ReplicatedStorage").statusText.Value)
-- they no longer print the same thing

Thanks! That updates the value now. Now I need to see why the local script isn’t updating the text. You can give me a hint, I’ll check on this forum in 5 minutes.

the local script should error.
local status = game:WaitForChild("ReplicatedStorage").statusText.Value
this points to the string that was contained in statusText at that point in time. Strings dont have changed events.

Like effectively what you have is

"Hello".Changed:Connect(function()

end)

you want to fix status so it references the StringValue, then listen to that StringValue’s Changed event. It will pass the new value to the event callback so you don’t need to manually look it up.

local status = game:WaitForChild("ReplicatedStorage").statusText

status.Changed:connect(function(value)
	script.Parent.Text = value
end)

Read the API page for that for more details StringValue | Roblox Creator Documentation