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

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

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)

1 comment

0

you can't fire client from a local script

2 answers

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)

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

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