I am using a remote that fires the server once a player clicks a button. The parameters are the the player itself and the player that it is targeting. These are in a local script. In another sever script, I have it connect to a function when the remote fires. However, when I print the parameters in the server script, they give me the same player even though printing them in the local script gives me two different players. Why? How do I fix it?
LOCAL SCRIPT
script.Parent.MouseButton1Click:Connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
local sendToText = script.Parent.Parent.PlayerName.Text
local playerModel = game:GetService("Players"):FindFirstChild(sendToText)
print(player)
print(playerModel)
game.ReplicatedStorage.RemoteEvents.PartyRequestSend:FireServer(playerModel)
end)
SERVER SCRIPT
local sendRemote = game:GetService("ReplicatedStorage").RemoteEvents.PartySendToClient
function sendInvite (player, playerSendTo)
sendRemote:FireClient(playerSendTo, player)
print(playerSendTo)
print(player)
end
partyRemote.OnServerEvent:Connect(sendInvite)
The first argument in a remote function/event when sending to the server is always the player that sent it, so there’s no need to add a player argument.
Sorry, but how would I change the FireClient parameters? I want it to fire to a specific client and include the parameter of who fire it. I fix the other problem though!
what do you mean fire to a specific client? the client is one thing that focuses on separate players individually. do you mean to Fire to certain players. You can do this:
Oh, my bad. Your FireClient function is fine, but when you fire the server, your first argument is unnecessary and causing the error. By default, OnServerEvent’s first parameter is the player that sent it.