Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

FireClient: player argument must be a Player object?

Asked by 4 years ago

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)

0
It's not firing? Well that's not good. Are there any errors? thebayou 441 — 4y

1 answer

Log in to vote
1
Answered by
thebayou 441 Moderation Voter
4 years ago
Edited 4 years ago

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)

0
For some reason the remoteevent doesnt fire anymore? UNBANhappyniceguy5 52 — 4y
Ad

Answer this question