PlayerGUI to SurfaceGUI text

  1. What do you want to achieve? I’m working on a PlayerGUI to Surface Text thing, for presenting ideas ingame.

  2. What is the issue? The issue is that whenever I click the button to change the text, it Didnt work at all at first, but then it decided to work, but only part of the way, & it clears the text instead of making it to the text that the player input.
    https://gyazo.com/125c0d7ad344e3f1d66fa2754a7c2fad

  3. What solutions have you tried so far? None so far, I tried to look, but the one I found I couldn’t get my head around it it was for a airport group & i didn’t understand that.

--ServerScript With Remote Event to change the text

--local instances
local Text = workspace.EthicsTable.SCREEN.Screen.SurfaceGui.TextLabel
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
--Script
RemoteEvent.OnServerEvent:Connect(function(TextChange)
	print("lol")
	Text.Text = script.Parent.Parent.Parent.InputFrame.TextBox.Text
end)
--LocalScript With script to fire the remote event to change the text on the SurfaceGUI to the text on the PlayerGUI

local RemoteEvent = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
	RemoteEvent:FireServer()
end)


image (This is an image of what the GUI looks like expanded)
image This is what the GUI looks like

And we are trying to get the text to here

1 Like

Well, that’s not how you’re supposed to use remote events.

Remote events go between a local script on the client and a script on the server. StarterGui is client, so you have 2 scripts on the client.

The local script is good but place the script inside the surface GUI you want to change.

Now, send the text as an argument to the remote event.

Local script

local RemoteEvent = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
	RemoteEvent:FireServer(script.IDK.Text) -- place the textLabel.Text inside the parenthesis
end)

Script

local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent.OnServerEvent:Connect(function(TextChange)
	workspace.EthicsTable.SCREEN.Screen.SurfaceGui.TextLabel.Text = textChange
end)

There is no “local” on a script, that’s why it doesn’t have local on it’s name. Scripts are server sided, local scripts are client sided. Remote events connect between client and server. There is no “server” on StarterGui.

Hope this helped, happy coding

I did what you told me for the script, but it only gave me an error

Well yes, the argument’s name is TextChange, not textChange. Just switch it

I changed the lowercase T to a uppercase T, but I still got an error, Ill send the LocalScript to see if its a problem I messed up with the localScript.

It’s a problem with the local script, you’re sending an Instance not a String. You’re sending a textLabel and not it’s text.

local TextBox = script.Parent.Parent.Parent.InputFrame.TextBox
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
	RemoteEvent:FireServer(TextBox.Text) -- place the textLabel.Text inside the parenthesis
end)

Thats what the LocalScript looks like on my side, I had to do Local Textbox, because the Textbox’s text is the text that needs to change the Ethics Table Screen ScreenGUI & its parented a little while away.

The first parameter of RemoteEvent.OnServerEvent is the client who fired the remote.

To fix this, just add a player variable before TextChange:

...OnServerEvent:Connect(function(player, TextChange)

end)
1 Like

Thank you, By adding the Player, Textchange to his script, which btw @AvionicScript Thank you for your massive help, It allowed it to work

1 Like

Ah yes I totally missed that, that should work now.