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

FireClient: player argument must be a Player object?

Asked by 3 years ago
Edited 3 years ago

Error : FireClient: player argument must be a Player object

Script :

script.Parent.Touched:Connect(function()
     script.Parent.RemoteEvent:FireClient()
end)

Local script :


local Player = game.Players.LocalPlayer script.Parent.RemoteEvent.OnClientEvent:Connect(function() local Menu = Player.PlayerGui:WaitForChild("Menu") Menu.Frame.Visilbe = true Menu.Close.Visible = true end)

1 answer

Log in to vote
1
Answered by
Neatwyy 123
3 years ago

You need to put a player in between the brackets of FireClient(). To get the player, you would have to get the character that touched the part, then take the name of that character and navigate through game.Players. Here's an example.

--  Server Script

script.Parent.Touched:Connect(function(hit) -- hit is the part that touched script.Parent 
    if hit.Parent:FindFirstChild("Humanoid") then -- Checking for a humanoid
        local plr  = game.Players:FindFirstChild(hit.Parent.Name)

        if plr then -- Checking if the player exists
            script.Parent.RemoteEvent:FireClient(plr)
        end
    end
end)

Hope it helps!

Ad

Answer this question