How do I find player object in an RE?

To be clear, it may be obvious (it wasn’t to me until I started researching), RE stands for RemoteEvent (lool, most of you guys probably knew that)

Anyways, I am trying to fire a RemoteEvent to the client that will start a camera tween (all this is through a BindableEvent, not important because I’ve made sure that it works but thought I should say it). I do not know whether the tween works, although I think it does but I haven’t been able to test it in a RemoteEvent.

Code (Client and Server):

-- Server sided (Script in ServerScriptService)
script:WaitForChild("Event").Event:Connect(function(player)
       print("fired")
       game.ReplicatedStorage.ActivateTween:FireClient(player)
end)
-- Client (LocalScript in StarterGui)
game.ReplicatedStorage.ActivateTween.OnClientEvent:Connect(function()
	local TweenService = game:GetService("TweenService")

	local cutsceneTime = 1

	local camera = game.Workspace.Camera

	local tweenInfo = TweenInfo.new(
		cutsceneTime,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)

	local function tween(part1, part2)
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CFrame = part1.CFrame
		local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
		tween:Play()

		wait(cutsceneTime)
		camera.CameraType = Enum.CameraType.Custom
		print("CutsceneDone")
	end

	wait(2)

	tween(game.Workspace.Test1,game.Workspace.Test2)

end)

Now the hard part! Getting the player object (everyones favorite part of RemoteEvents)!!! I get an error in the Output saying this…

18:16:18.315 FireClient: player argument must be a Player object - Server - MainController:5

I should also make it clear- I have tried researching this, and have had no luck what so ever. Including developer forums topics, it still doesn’t work.

what happens when you print player in the server script? it sounds like your failing to supply the bindable event with a player

How do I find a player for the bindable event and then pass it over to the remote event

Can you post where you call Event:Fire? it should look like script:WaitForChild("Event").Event:Fire(player)

script:WaitForChild("QueueAnimation").Event:Connect(function(player)

print("fired")

game.ReplicatedStorage.ActivateTween:FireClient(player)

end)

is this what you meant?

On “MainController” line 3 you define script:WaitForChild("Event").Event:Connect(function(player). where is this event being fired from? I don’t believe you’re passing it a player

from a part in workspace. also, i am not passing the player. How do I do this?

script:WaitForChild("Event").Event:Fire(player) Like this, you pass the player argument to the event’s Fire. It would help to see the actual script firing this event.

Oh, thought you meant something else. I’m firing this from ServerScriptService. I’ve looked at some of Roblox’s code and they did this. For some reason, it isn’t working for me. May it be that this is from a bindable event function?

Issue lies on the line

game.ReplicatedStorage.ActivateTween:FireClient(player) -- The player parameter is not the object in itself

Thus you need to check where your bindable event is fired.
Could you provide us the portion of the code where you are firing the bindable event?

1 Like

I’m even more confused, please post the script, or the part of it with Event:Fire(player) you can search for this with ctrl+shift+f

This issue likely has nothing to do with remote events

1 Like

The BindableEvent is fired inside a part.

-- Fires bindableevent (to server)

script.Parent.Touched:Connect(function(player)
	game.ServerScriptService.MainController.QueueAnimation:Fire(player)
end)

QueueAnimation is a BindableEvent inside a script in ServerScriptService

this is what receives it (and then fires the remote event, which is where I run into my problem.

print("Script up and running.")

script:WaitForChild("QueueAnimation").Event:Connect(function(player)
	print("fired")
	game.ReplicatedStorage.ActivateTween:FireClient(player) -- Fires remote event to client
end)

ActivateTween is a RemoteEvent in ReplicatedStorage.

So now, the problem is this, on line three of the script that receives the BindableEvent (the script on the bottom of the 2 scripts here), is that I need to find a player object.