Can't Fire A Event When A Dummy Dies

Semi works, still only works with one robot. When killing the other robot, still the same error with FireClient: player argument must be a Player object

Try this:

human.Died:connect(function()
if human:FindFirstChild("Player_Tag") then
local plr = human.Player_Tag.Value
local Type = "EnemDeath"
DeatghEv:FireClient(plr,Type)
end
end)

Why are we looking through the npcs humanoid for the player tag?

script inside the tool

local tool = script.Parent
local PS = game:GetService("Players")
local debounce = false

tool.Handle.Touched:Connect(function(hit)
if PS:GetPlayerFromCharacter(script.Parent) and debounce == false then
local plr = PS:GetPlayerFromCharacter(script.Parent)
if hit.Parent:FindFirstChild("Humanoid") and and not plr:IsA("Player")  then
local enemyhuman = hit.Parent.Humanoid
if not enemyhuman:FindFirstChild("Player_Tag") then
local tag = Instance.new("ObjectValue", enemyhuman)
tag.Name = "Player_Tag"
tag.Value = plr
end
debounce = true
wait(1)
debounce = false
end
end)

script inside the npc

human.Died:connect(function()
if human:FindFirstChild("Player_Tag") then
local plr = human.Player_Tag.Value
local Type = "EnemDeath"
DeatghEv:FireClient(plr,Type)
wait(0.1)
human.Player_Tag:Destroy()
end
end)

Doesn’t work at all now. No errors or anything. But why are we checking the npcs humanoid for the value?

It doesn’t have to be inside the humanoid, it can be inside the npc, I put it through a script that it’s inside the humanoid.

Try to remove IsA(“Player”) inside the tool script.

if hit.Parent:FindFirstChild("Humanoid")  -- and  not plr:IsA("Player")  - -This then

But then you will have to change the name of the humanoid to something else, because then it will happen that the script puts value inside the player humanoid.

Im so confused. I honestly don’t even know what to do when you mean change the name of the humanoid to something else. I don’t even know if I should continue this script if its this much pain.

Or just insert folder inside the npc named “FolderValue” then.

Tool script

tool.Handle.Touched:Connect(function(hit)
if PS:GetPlayerFromCharacter(script.Parent) and debounce == false then
local plr = PS:GetPlayerFromCharacter(script.Parent)
if hit.Parent:FindFirstChild("FolderValue") hen
local folder = hit.Parent.FolderValue
if not folder:FindFirstChild("Player_Tag") then
local tag = Instance.new("ObjectValue", folder)
tag.Name = "Player_Tag"
tag.Value = plr
end
debounce = true
wait(1)
debounce = false
end
end)

NPC script

human.Died:connect(function()
local folder = npc.FolderValue
if folder:FindFirstChild("Player_Tag") then
local plr = human.Player_Tag.Value
local Type = "EnemDeath"
DeatghEv:FireClient(plr,Type)
wait(0.1)
folder.Player_Tag:Destroy()
end
end)

That’s the only way you don’t have to change the name of the humanoid within the npc.

here’s another solution.
You can delete script inside the tool
Here: (I’m not sure if this is a good solution)

game.Players.PlayerAdded:Connect(function(plr)
human.Died:Connect(function()
local Type = "EnemDeath"
DeatghEv:FireClient(plr,Type)
end)
end)

I don’t know any more solutions for this, because it is difficult to find a player inside a server script.

The bottom one works great now. Sorry for the late reply!

1 Like