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

:FireClient() isn't working? FireClient: player argument must be a Player object?

Asked by 4 years ago
Edited 4 years ago

Getting this error from a script im working on: FireClient: player argument must be a Player object.

Anyone know whats wrong?

--script
local remotes = game:GetService("ReplicatedStorage"):WaitForChild("IRemotes")
local br = remotes:WaitForChild("BroadcastRemote")
local player = game.Players.LocalPlayer


script.Parent.Touched:Connect(function()
    print("TouchedBorder")
    br:FireClient(player)
end)
--localscript
local remotes = game:GetService("ReplicatedStorage"):WaitForChild("IRemotes")
local br = remotes:WaitForChild("BroadcastRemote")

br.OnClientEvent:connect(function()
    script.Parent.Visible = true
    wait(3)
    script.Parent.Visible = false
end)
0
you can't fire client from a local script Robowon1 323 — 4y

2 answers

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
4 years ago
Edited 4 years ago

Why are you firing client when it seems you're using a LocalScript?

If it's a server script, then you need to define the player using GetPlayerFromCharacter().

Remove your player variable and edit your touched function to this.

script.Parent.Touched:Connect(function(otherPart) -- On touched, define part
    local player = game:GetService('Players'):GetPlayerFromCharacter(otherPart.Parent) -- find player
    if player then -- if player found
        br:FireClient(player)
    end
end)
Ad
Log in to vote
0
Answered by
Launderer 343 Moderation Voter
4 years ago

You need to define which player inside the parenthesis of the FireClient function

Answer this question