I need help with Round GUI script

Hi, I’m trying to change the text of the gui every time a new round starts but the gui does not update, you have to reset to see the new text. I appreciate any help

Script:

local value = script.Parent.Value

local function onvalue(new)
	script.Parent.Text = "Round "..new
end

value.Changed:Connect(onvalue)

script.Parent.Text = "Round "..value.Value
1 Like

try this script

local value = script.Parent

local function onvalue(new)
	script.Parent.Text = "Round "..new
end

value.Changed:Connect(function()
onvalue(value.Value)
end)

script.Parent.Text = "Round "..value.Value

Unfortunately it doesn’t work, ty too.

Can we see the screenshot of the object value and its corresponding location?

you are using a .Changed event, so anything in the base that was changed will connect with the changed value and give you another result.

To fix this you have to use value:GetPropertyChangedSignal("Value") so you’re able to change the text and avoid receiving errors that the context is not a string.

In other notes, using .Changed Event will give you the name of the property that was changed, so in your statement the “new variable” will give you “Round Value”

1 Like

It is under a textlabel, so in starterGUI

Based on that I derive 2 assumptions:

  1. You change the StarterGui value not the PlayerGui value for all the clients.
  2. The UI has ResetOnSpawn set to true.

To fix the issue you have 3 options:

  1. Use remotes - If you use remotes the client will have to send a request to the server when their UI loads and listen to the server sending them requests when the value changes.
  2. Directly modifying the value - You can change the StarterGui value and also loop through all the players currently in the game and change the PlayerGui value on the server, this will replicate to them.
  3. You can parent the value in ReplicatedStorage, so all the changes the server makes to it replicate to the client.

I think option 3 is the easiest to implement since you don’t have to modify anything other than changing the Value parent to ReplicatedStorage:

local val = game.ReplicatedStorage.Value

function onChanged(value)
	script.Parent.Text = "Round "..value
end

onChanged(val.Value)
val.Changed:Connect(onChanged)

and of course change that in your server script as well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.