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

FireClient: player argument must be a Player object?

Here's my script, in the print(Player) I get my player name so shouldn't it work?

local Debounce = false
script.Parent.Touched:Connect(function(Object)
    if Object.Parent:FindFirstChild("Humanoid") then
		local player = Object.Parent
		print(player)
		game.ReplicatedStorage.JoinTeam:FireClient(player)
	end
end)

1 comment

0

It's not firing? Well that's not good. Are there any errors?

1 answer

✓ Accepted answer

What you need is :GetPlayerFromCharacter since FireClient takes a player, not the object that touched the part (which is what Object.Parent is)

So:

local Debounce = false
script.Parent.Touched:Connect(function(Object)
    if Object.Parent:FindFirstChild("Humanoid") then

        local player = game:GetService("Players"):GetPlayerFromCharacter(Object.Parent)	-- This is the line that matters. :GetPlayerFromObject is a member of the Players service.

        print(player)
        game.ReplicatedStorage.JoinTeam:FireClient(player)
    end
end)

1 comment

0

For some reason the remoteevent doesnt fire anymore?

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