I need help with RemoteEvents

Basically, i am making a script to change a value in ReplicatedStorage to something is written on a TextBox but i can’t seem to figure it out, can someone help me here please?

LocalScript:

local button = script.Parent
local box = script.Parent.Parent.TextBoxA
local event = game.ReplicatedStorage.Events.Setpoints_A

button.MouseButton1Click:Connect(function()
	local text = box.Text
	event:FireServer(text)
end)

Script:

game.ReplicatedStorage.Events.Setpoints_A.OnServerEvent:Connect(function(text)
	game.ReplicatedStorage.Event.Value = text
end)

The output Says:
invalid argument #3 (string expected, got Instance)

I don’t see anything wrong off the bat, but maybe use tostring()

1 Like

Try changing it to:

game.ReplicatedStorage.Events.Setpoints_A.OnServerEvent:Connect(function(Player,text)
	game.ReplicatedStorage.Event.Value = text
end)

These are the parameters for OnServerEvent:

https://developer.roblox.com/en-us/api-reference/event/RemoteEvent/OnServerEvent

1 Like

You’ve forgotten that whenever you are using the RemoteEvent.OnServerEvent, the first argument is always the player that fired the RemoteEvent.

2 Likes