FireClient suddendly not working

Im making a teleport script thing, and suddenly the fireClient script doesn;t work anymore.
The error is this: FireClient: player argument must be a player object

The only problem I am having now is that I am giving the event a player object.

	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	workspace.inCave:FireClient(plr, "out")

Can anyone explain this weird error to me?

The plr variable might be nil, if the hit.Parent wasn’t a character. So you need to check if it isn’t nil and then fire it.

You want to make sure its a player character, otherwise, it won’t give you a player object with :GetPlayerFromCharacter

local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil then