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

Why Do I Error On This Client Event Call?

local TPERS = {script.Parent.P1, script.Parent.P2, script.Parent.P3, script.Parent.P4, script.Parent.P5, script.Parent.P6, script.Parent.P7,
script.Parent.P8, script.Parent.P9, script.Parent.P10, script.Parent.P11, script.Parent.P13, script.Parent.P14, script.Parent.P5, script.Parent.P6}
	
	
for _, v in pairs (TPERS) do
	v.Touched:Connect(function(hit)
		local humanoid = hit.Parent:WaitForChild("Humanoid")
			if humanoid then
				game.ReplicatedStorage.EventsAndValues.Portal:FireClient(hit.Parent)
		end
	end)
end

Error - FireClient: player argument must be a Player object

2 answers

✓ Accepted answer

As the error says, it must be a player object. You're trying to pass the player's Character. This can be easily fixed by using the Players:GetPlayerFromCharacter function to get the player from their character.

local TPERS = {script.Parent.P1, script.Parent.P2, script.Parent.P3, script.Parent.P4, script.Parent.P5, script.Parent.P6, script.Parent.P7,
script.Parent.P8, script.Parent.P9, script.Parent.P10, script.Parent.P11, script.Parent.P13, script.Parent.P14, script.Parent.P5, script.Parent.P6}

for _, v in pairs (TPERS) do
    v.Touched:Connect(function(hit)
        local humanoid = hit.Parent:WaitForChild("Humanoid")
            if humanoid then
			local Player = game.Players:GetPlayerFromCharacter(hit.Parent)								 
 			game.ReplicatedStorage.EventsAndValues.Portal:FireClient(Player)
        end
    end)
end

The first argument of :FireClient() must be a player that the event is being fire to. If you're trying to make it fire to every client, use :FireAllClients()

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