Firing Client Issues

This is supposed to fire the client, but how come it keeps coming back with the Hit must be Player Object error?

part = script.Parent
remote = game.ReplicatedStorage.RemoteEvent

part.Touched:Connect(function(Hit)
	local hitParent = Hit.Parent
	local humanoid = hitParent:FindFirstChild("Humanoid")
	if humanoid then
		remote:FireClient(Hit)
	end
end)
2 Likes

When you fire the remote with the object you refer to as (Hit) you’re firing the remote with the object that touched the part

Lets say for example you were to walk on the part, it would fire the client, not to a player, but to (“Left Leg”) which isnt a player

Long story short, if Hit.Parent finds a humanoid which means its a player/character, then it is equals to the bodypart that hit the part, and FireClient is sending a signal to a player, when you do FireClient(Hit) you’re firing the remote to your body part, which isnt a player, a player is an instance in the game.Players, which is also what you need to fire the client to.

Instead do this


part = script.Parent
remote = game:GetService("ReplicatedStorage").RemoteEvent

part.Touched:Connect(function(Hit)
	local humanoid = Hit.Parent:FindFirstChild("Humanoid")

	if humanoid then
        local player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
		remote:FireClient(player)
	end
end)
3 Likes

Could we see where is this script located and what are you trying to do? This could be due to the running on server

3 Likes

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