Event not firing correctly (Player, Message)

Hi everyone!

I’m trying to create an in-game messaging system that staff members in a group can use, but I’m having some trouble, I can’t seem to figure out.

When the event is fired to send a message, it thinks the “Message” part is the “Player” part, even though it knows the player part is the message?

Here’s a screenshot from in the game and the code. Please help fix this!

Note: I know that it thinks its the player as I had it print the Message Result as a string and it sent my name.

Client Sided:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local AnnouncementOpen = true
local Box = script.Parent.MessageFrame.TXTBox

script.Parent.AnnounceBtn.MouseButton1Down:Connect(function()
	if AnnouncementOpen == false then
		script.Parent.AnnounceFrame.Visible = true
		AnnouncementOpen = true
	else
		script.Parent.AnnounceFrame.Visible = false
		AnnouncementOpen = false
	end
end)


Box.FocusLost:Connect(
	function(Enter)
		if Enter then
			print(Box.Text)
			local Text = Box.Text
			game.ReplicatedStorage.RemoteEvent:FireServer(Player, Text)
		end
end)

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(Player, Message)
	local Message = script.MessageTemplate:Clone()
	Message.MessageTemplate.Text = tostring(Message)
	Message.PlayerName.Text = Player.Name
	Message.Parent = script.Parent.MessageFrame.ScrollingFrame
end)

Server Sided:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, Message)
	if not Message then
		print("No Message")
		return
	end
	game.ReplicatedStorage.RemoteEvent:FireAllClients(Player, Message)
end)

Screenshot:
(posthanix is my username, the “MessageTemplate” is the default unchanged template text.
image

So sorry if this is a bother!

There is no need to put Player within your FireServer arguments, the player object is automatically passed and received in the first argument of OnServerEvent.

Client side should read:

game.ReplicatedStorage.RemoteEvent:FireServer(Text)

I changed it. While it still works, it still isn’t getting the message.

It does now print the actual message but isn’t setting it. I removed tostring, and get this error:

Line 29:

	Message.MessageTemplate.Text = Message

Maybe if you change it to a string: tostring(Text).

image
Yeah, that was it. Oops. It was making the text Message.

Try removing the Player argument from your OnClientEvent.