RemoteEvent:FireClient() passing argument as nil?
Asked by
asgm 109
5 years ago
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):
2 | game:GetService( "ReplicatedStorage" ).EventsFolder.ServerMessageEvent |
3 | local Player = game.Players:GetPlayerFromCharacter(hit.Parent) |
4 | local text = "You have been given " ..Points.Value.. |
5 | " Points for completing the map with the score of " |
7 | MessageEvent:FireClient(Player,text) |
And this is the local script that's supposed to fire:
01 | MessageEvent = game:GetService( "ReplicatedStorage" ).EventsFolder.ServerMessageEvent |
03 | MessageEvent.OnClientEvent:Connect( function (Player,text) |
06 | game.StarterGui:SetCore( "ChatMakeSystemMessage" , { |
07 | Text = ( "[Server]:" ..text); |
08 | Font = Enum.Font.SourceSansBold; |
09 | Color = Color 3. new( 237 , 255 , 114 ); |
10 | FontSize = Enum.FontSize.Size 18 } ) |
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)
1 | asgm has beaten The First Map with the score of 11 ! |
4 | You have been given 6 Points for completing the map with the score of 11 |
5 | 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:
1 | asgm has beaten The First Map with the score of 11 ! |
3 | 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")