Why are they printing the same thing?

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)

1 Like

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.

1 Like

Oh! This guide misinformed me/confused me… Custom Events and Callbacks | Documentation - Roblox Creator Hub Let me try fixing it

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! :slight_smile:

local sendRemote = game:GetService(“ReplicatedStorage”).RemoteEvents.PartySendToClient

Nowhere in the script you’re actually firing to the client. You defined the variable, but didn’t fire it.

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:

event:FireClient(player) -- define event

1 Like

Oops, I was referring to a local script I did not post in my original post. Sorry if that wasn’t clear. Here it is

local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("PartySendToClient")

function showGUI(player, playerWhoSent)
	print(player)
	print(playerWhoSent)
	script.Parent.SenderName = playerWhoSent.Name
	script.Parent.Visible = true
end

remote.OnClientEvent:Connect(showGUI)

That still doesn’t show us where you’re firing to the client, it would look like this: remote:FireClient(Player)

It is in the original post’s server script. I used :FireClient.

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.

1 Like

Hm, I fixed that, but my playerWhoSent parameter still prints nil. Does it have to do with purposely switching up the parameters in the server script?

Could you show me your updated script?

I updated it in the original post.

Is there any reason why you put in a function as an argument?

Um, I’m not sure what you are referring to…sorry.

Nevermind I thought it said something else.

Are you sure this is a player?

Yes, I printed it and it prints the player’s name.