Hello! When I run my script, it gives me the output invalid argument #3 (string expected, got Instance). Does anyone have any idea how this occurred and how I can fix it?
Here is a short summary of what I’m trying to do.
When a TextButton is clicked, it should get the Text out of a TextBox, and put the textbox text into a TextLabel, for an announcement sort of thing. I am using a remote event to do this.
Fire Script: (The script that fires the remote event)
local event = game.ReplicatedStorage.Announce
local input = script.Parent.Parent.InputText
local announcetext = script.Parent.Parent.Parent.TextLabel
script.Parent.MouseButton1Click:Connect(function()
input.Text = "Announcing your message.. please wait."
input.TextEditable = false
wait(2)
event:FireServer(input,announcetext)
input.Parent.Visible = false
script.Parent.Parent.Parent.AdminPanelGui.Visible = true
input.TextEditable = true
end)
And here is the Server script: (The stuff that the remote event should do)
local Event = game.ReplicatedStorage:WaitForChild("Announce")
Event.OnServerEvent:Connect(function(input,announcetext)
announcetext.Text = input
end)
The error is apparently going wrong at announcetext.Text = input according to the debug.
No need to post the same thing twice. That’s because when receiving events from the server, the first argument would always be the Player that fired the event!
Another tip: WaitForChild isn’t necessary for objects in ReplicatedStorage because they’re already loaded in by the time scripts in ServerScriptService run.