Message returns nil

Hey! I am currently working on an in-game chat log where it shows what the player has said.

When I run it on the client side through a remote event the message returns nil and I am unsure why.

Command Code (ServerScript):

local rs = game:GetService("ReplicatedStorage")
local event = rs.Events.chatEvent

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		--print(msg)
		event:FireClient(player, msg)
	end)
end)

Local Script:

local rs = game:GetService("ReplicatedStorage")
local event = rs.Events.chatEvent

local ui = script.Parent
local Frame = ui:WaitForChild("Frame")
local ScrollingFrame = Frame:WaitForChild("ScrollingFrame")
local template = ScrollingFrame:WaitForChild("Template")

event.OnClientEvent:Connect(function(player, msg)
	template.Text = "max123lover2 said: ".. msg
end)

Please, help if possible.

You dont need the player variable in the OnClientEvent connection in your local script, consider removing that.

1 Like

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