I'm trying to make a server chat message for the client, but somehow when I pass a player argument for :FireClient(), it went missing when it reaches the message script.
This is the :FireClient() message (server script):
local MessageEvent =
game:GetService("ReplicatedStorage").EventsFolder.ServerMessageEvent
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
local text = "You have been given "..Points.Value..
" Points for completing the map with the score of "
..Score.Value
MessageEvent:FireClient(Player,text)
And this is the local script that's supposed to fire:
MessageEvent = game:GetService("ReplicatedStorage").EventsFolder.ServerMessageEvent
MessageEvent.OnClientEvent:Connect(function(Player,text)
print(text)
print(Player)
game.StarterGui:SetCore("ChatMakeSystemMessage",{
Text = ("[Server]:"..text);
Font = Enum.Font.SourceSansBold;
Color = Color3.new(237, 255, 114);
FontSize = Enum.FontSize.Size18})
end)
And this is what it prints out: (the first 2 lines are from FireAllClients,which sends the server message to the whole server.) (server chat messages are client-sided,which is why i'm doing this)
asgm has beaten The First Map with the score of 11!
asgm
nil
You have been given 6 Points for completing the map with the score of 11
08:23:43.633 - Players.asgm.PlayerGui.ServerMessage:17: attempt to concatenate local 'text' (a nil value)
as you can see, print(Player) prints out the text instead of "asgm" while (text) goes missing. When I remove the "Player" argument, it prints out this:
asgm has beaten The First Map with the score of 11!
asgm
08:16:20.382 - Unable to cast value to Object
Is there something I'm missing? (forgive me if my use of the word "argument" is misleading i don't use it quite often since i often get confused with the term "argument" and "parameter")

3 comments
Don't send me wiki links unless necessary to overcome my stupidity, I understand english good,but Lua bad.
OnClientEvent only requires the arguments that you're sending, not the player. When you removed the player from line 3 in the LocalScript, did you also remove line 5? https://developer.roblox.com/en-us/api-reference/event/RemoteEvent/OnClientEvent
Oh,really? I thought client events automatically creates or sets a player argument as the first argument,wether there's no argument or there's 1 argument. and yes,I think the (text) argument is nil which is why it throws an error. I solved this by rearranging the arguments to (text,Player) instead of (Player,text) which I should've thought earlier :/ (Player is still nil, how do you get player?)