Firing RemoteEvents

Hi, I’m a new scripter and I’m just experimenting with RemoteEvents to learn client-server interactions. However, my script isn’t working as when I put a word into the TextBox, the SurfaceGui just reads back as “TextBox”.

Here’s the code in the normal Script:

local text = script.Parent.TextBox
local target = game.Workspace.SignPart.SurfaceGui.TextLabel

RemoteEvent.OnServerEvent:Connect(function(player)
	if player then
		local update = text.Text
		
		target.Text = update
	end
end)```

And here's the code in the LocalScript

```local button = script.Parent.TextBox
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

local function onFocusLost(enterpressed)
	if enterpressed then
		RemoteEvent:FireServer()
	end
end

button.FocusLost:Connect(onFocusLost)

Try sending the text variable as a parameter

1 Like

I see the problem here. When you type in text in your textbox, you see the changes on the client, but they don’t replicate to the server. This is actually why you should be using a remote event through a replicated storage : to send to the server which changes were made.
You then have to add a param to your FireServer which is the text of the textbox, here being text.Text. On the server, when you connect to your remote event and check for ServerEvents with a function, you have the player parameter (automatically added) and your additional params. Your additional param here is the text of the textbox.
On client :

RemoteEvent:FireServer(text.Text)

On server :

RemoteEvent.OnServerEvent:Connect(function(plr, val)
    print(plr, "textbox text :", val)
end)