Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why am i getting FireClient errors when firing to enemy player?

Hello, I'm trying to make a script where once a player enters the hitbox, they will slow down and then create a ColorCorrection Effect. For the color correction i chose to go with a remote events that fires when a player hits the hitbox.

It kinda works, but i get spammed by errors in the console saying "FireClient: player argument must be a Player object"

The error will still occur even though the other player gets slowed down and gets applied with the color correction.

Any tips on how i could fix this? I'm trying to fire the remote for the enemy player and not my local player.

Part of Server Script

Hitbox.Touched:Connect(function(Hit)
	if Hitbox:IsA("BasePart") then
	if not Hit:IsDescendantOf(Char) then
		local enemy = Hit.Parent
		local enemyHumanoid = Hit.Parent:FindFirstChild("Humanoid")
		local enemyHumrp = Hit.Parent:FindFirstChild("HumanoidRootPart")

spawn(function()
	local enemyPlr = game.Players:GetPlayerFromCharacter(enemy)
	LightRemote:FireClient(enemyPlr)
end)

2 comments

0

Fix your scripts, you're missing 'end' for some scopes.

0

That is not the issue. This is not the entire script, and i am not missing any end's

1 answer

✓ Accepted answer

There's a good way to fix your problem.

Firstly, use print() to print the ClassName and Name of Hit.Parent:

print(Hit.Parent.ClassName, Hit.Parent.Name)

The reason I'm saying this is because, odds are, the part touching the hitbox is probably something else touching the hitbox that isn't the player. In that case you'd add a primary check to confirm that Hit.Parent is the player's Character:

if game.Players:GetPlayerFromCharacter(Hit.Parent) then

If this condition fails to pass it means whatever is touching the hitbox is not the player's Character.

1 comment

0

Thank you. The print function returned the player and the players hair for some reason.

This discussion is preserved as it was. New answers, comments, and votes are closed.