Arguement with player object on fire:client() / GetPlayerFromCharacter doesn't work

What I want to do is when click the part. The camera moves.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

script.Parent.ClickDetector.MouseClick:Connect(function (click)
	
	if click then
		print("yes")
		ReplicatedStorage._ClickIngredient:FireClient(game.Players:GetPlayerFromCharacter(click.Parent), script.Parent)
	end
	
end)

I’ve tried GetPlayerFromCharacter(click.Parent) and it still giving the same result

MouseClick returns the Player that clicked the ClickDetector as the first parameter. So in this instance, click is the player object.

game.Players:GetPlayerFromCharacter(click.Parent)

would return nil, as the parent for click is the Players service. You should just pass click as the player parameter for the FireClient method.

ReplicatedStorage._ClickIngredient:FireClient(click, script.Parent)
1 Like

Thank you so much. I understand now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.