[Solved] .Text Property of a GUI Not Updating

Hello there, my goal is simple:

  1. Get the .Text value of a TextBox
  2. Get the variable for a TextLabel (in a different ScreenGUI)
  3. Listen for a MouseButton1Click
  4. Update the TextLabel.Text to the TextBox.Text for all players

Here is my code:

– client –

script.Parent.MouseButton1Click:Connect(function()  

	local flightnumber = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("cloudife2").cloudife.home.flightnumber
	local box = script.Parent.Parent.flightnumber

	flightnumber.Text = box.Text
	game.ReplicatedStorage.cloudife.update:FireServer(flightnumber, box)

end)

– server –

game.ReplicatedStorage.cloudife.update.OnServerEvent:Connect(function(player, flightnumber, box)
	flightnumber.Text = box
end)

On the client, the .Text property updates, but on the server, it only changes the property it self, but does not actually update on the screen.

3 Likes

ok never mind, I just tested it and it worked fine for me.

is your code erroring?

1 Like

No, the console is empty

30 limit

Edit: The property it self does update on the server, but visually it does not update

1 Like

your issue could be here

local flightnumber = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("cloudife2").cloudife.home.flightnumber
local box = script.Parent.Parent.flightnumber

flightnumber.Text = box.Text

is box a different instance than flightnumber? If not then its setting the text to what it already is

Box is a different instance, check the above reply as I updated it

Are you saying that the text on the server “view” in Studio doesn’t update? If so, this is desired behaviour as the server doesn’t actually render anything at runtime, it just replicates and syncs data to players for their computers to render it on-screen.

1 Like

I tested this both on the server view and I tried running a local server, neither of them doesn’t work

1 Like

Okay, but on the client view does the text update?

1 Like

Yes, it does, but for everyone else it does not

1 Like

This is down to replication, it’s a very broad subject and I can’t cover it in-depth in a forum post but:

  • The interface you’re using is inside a PlayerGui, I’m guessing it’s a ScreenGui. This ScreenGui will only render on the player’s screen who’s PlayerGui it is inside of.
  • To make it update on everyones screen, you need to update everyones instance of the ScreenGui. This can likely be done using remote events
  • It’s very bad practice to update UI from a server script. It pretty much should never ever need to be done; I can’t imagine a single case where you would need to. I’d recommend reading up on networking, replication & remote events. All UI logic should be done locally by local scripts running on the clients computer
1 Like

The problem is that the server is not sending the text to the other clients. You need to recode your event handler to deal with it. Then on the clients, they have to listen for that event from the server so they will process the incoming message.

You need to have this on the server:

game.ReplicatedStorage.cloudife.update.OnServerEvent:Connect(function(player, text)
	flightnumber.Text = text
	game.ReplicatedStorage.cloudife.update:FireAllClients(text)
end)

Then the clients needs the event handler to process it.

game.ReplicatedStorage.cloudife.update.OnClientEvent:Connect(function(text)
	flightnumber.Text = text
end)

Don’t send the instances. They are unique to each client. Just send the text.

script.Parent.MouseButton1Click:Connect(function()  

	local flightnumber = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("cloudife2").cloudife.home.flightnumber
	local box = script.Parent.Parent.flightnumber

	flightnumber.Text = box.Text
	game.ReplicatedStorage.cloudife.update:FireServer(box.Text)

end)

That should get you going.

1 Like

Thank you so much! I just don’t usually work with GUI’s so yeah

1 Like

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