Wrong character is jumping

I want a player to press a button, which makes it sot hat the other player’s “partner” jumps. To do so, I have a local script and server script.
(Local)

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	print(""..player.leaderstats.Checkpoint.Value)
	local ControlledOne = game.Players:WaitForChild(player.PartnerData.Partner1.Value)
	print(""..ControlledOne.Name)
	script.Parent.ControlledJumpEvent:FireServer(player, ControlledOne)
end)

(Server)

script.Parent.ControlledJumpEvent.OnServerEvent:Connect(function(player, ControlledOne)
	print(""..ControlledOne.Name)
	ControlledOne.Character.Humanoid.Jump = true
end)

The problem is, im guessing, since the remote event is going from client to server, the player I’m trying to make jump is thought to be the player who presses the button. I’m wondering if I should simply do an alternative rather than client to server? Perhaps server to client to server? I’m not sure.

1 Like

The first parameter of :onServerEvent() is ALWAYS the player that triggered it. The following parameters are what you sent yourself. Basically, the first value of what you sent through FireClient() is actually the second value in OnServerEvent() and the second value you sent is the third value. If that makes sense.

Because of this, there is no need for you to be sending the player as a parameter yourself. In the Localscript, remove the player parameter from FireClient() and it should work.

4 Likes

By default, when a RemoteEvent is fired from the client to the server, the first parameter is the client who fired it. So, instead of writing:

script.Parent.ControlledJumpEvent:FireServer(player, ControlledOne)

You would write:

script.Parent.ControlledJumpEvent:FireServer(ControlledOne)

Funny thing is, I actually did not know that about parameters, so not only have you helped me here but you’ve helped me for time to come. Huge thanks!