How to get text from a ui to a server

local replicatedStorage = game:GetService(“ReplicatedStorage”)

local announceEvent = replicatedStorage:WaitForChild(“AnnounceEvent”)

local button = script.Parent

local textBox = script.Parent.Parent.Parent.TextBox

local plr = game.Players.LocalPlayer

button.MouseButton1Click:Connect(function()

local msg = textBox.Text

announceEvent:FireServer(plr,msg)

end)

Im trying to send the text from the textbox to server and im kind of stuck on this
whenever i send the text it comes up as the player name not text

FireServer already sends the player with the event, so when you recieve the event with OnServerEvent, the first variable is always the player. So when you add your own player variable the second variable is also the player.

Example:

-- Client
announceEvent:FireServer(msg)

-- Server
announceEvent.OnServerEvent:Connect(function(plr, msg)
      print(msg)
end)

Ok ill try this now thanks alot

I recommend checking out the official documentation for remote events:

ye i should thanks for the link its just ive been coding for few years and took a long break so tryin to wrap my head around things again but ye i really appreciate

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