FireClient: player argument must be a Player object!

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    -I want to spawn a dummy whenever a player touch a part.
  2. What is the issue?
    -I completed the summoning part. So basically, if a player touched a part, the script will get the name using “hit”. This is the fire script.
script.Parent.Touched:Connect(function(hit)
	if not debounce then
		debounce = true
		
		local remote = rep:WaitForChild("Snake")
		
		local target = hit.Parent
		local dum = Storage.Dummy:Clone()
		
		dum.Parent = game.Workspace.AInow
			
		dum.HumanoidRootPart.CFrame = spawner.CFrame
		
		wait(cd)
		debounce = false
		
		remote:FireClient(target)
	end
end)

this is the local script that recieve the “target”

local remote = game.ReplicatedStorage.Snake

remote.OnClientEvent:Connect(function(target)

	script.Parent.spotter.Name = target.Name

	script.Parent.Parent["AI Chase"].Disbaled = false

end)

this should work fine, the dummy spawned but the value didn’t change. The output say “FireClient: player argument must be a Player object”
3. What solutions have you tried so far?
-I searched on the internet about fire event, but it seems like i used them corretly…
-I used fire client on a server script and OnClientEvent on a local script.

Pls help! Anyhelp would be appreciate…

2 Likes

I recommend checking for player like so


local Player = game.Players:GetPlayerFromCharacter(Target) -- I probs misspelled ze function :cri:

if Player then
remote:FireClient(Player)
end

https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerFromCharacter

3 Likes
script.Parent.Touched:Connect(function(hit)
	local target = hit.Parent
	local player = game.Players:GetPlayerFromCharacter(target)

	if not debounce and player then
		debounce = true
		
		local remote = rep:WaitForChild("Snake")
		
		local dum = Storage.Dummy:Clone()
		
		dum.Parent = game.Workspace.AInow
			
		dum.HumanoidRootPart.CFrame = spawner.CFrame
		
		wait(cd)
		debounce = false
		
		remote:FireClient(player, target)
	end
end)
2 Likes

You are taking the target as the character.
You need to pass the player as the first argument.

The player whose character touched the part.

target = game.Players:GetPlayerFromCharacter(hit.Parent)

if target then
remoteEvent:FireClient(target)
end

I didn’t notice at first glance @Zohair_028

But , hit.Parent would be a CharacterModel (Not always) and you cant call :GetPlayerFromCharacter() method because it is a model

Players:GetPlayerFromCharacter(CharacterModel)

the local script can’t receive!

the local script can’t receive!