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 :

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

Local script :

1local Player = game.Players.LocalPlayer
2 
3script.Parent.RemoteEvent.OnClientEvent:Connect(function()
4        local Menu = Player.PlayerGui:WaitForChild("Menu")
5        Menu.Frame.Visilbe = true
6        Menu.Close.Visible = true
7end)

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.

01--  Server Script
02 
03script.Parent.Touched:Connect(function(hit) -- hit is the part that touched script.Parent
04    if hit.Parent:FindFirstChild("Humanoid") then -- Checking for a humanoid
05        local plr  = game.Players:FindFirstChild(hit.Parent.Name)
06 
07        if plr then -- Checking if the player exists
08            script.Parent.RemoteEvent:FireClient(plr)
09        end
10    end
11end)

Hope it helps!

Ad

Answer this question