0

# How Do I fire a remote event after my NPC health is 0?

Edited by youtubemasterWOW 11 months ago

Hi, so I have a normal script inside of an NPC/rig and I want that script to fire a remote event So that my quest GUIs value on the screen will change to 1 and I really need help with this.When ever I try and fire a remote event it says that I need a player function when I have the function connected to the player funtion.Yet any other script works like if I want to print Hi.

Normal script:

local Humanoid = script.Parent.Humanoid
local event = game.ReplicatedStorage:WaitForChild("Human1")

Humanoid.Died:Connect(function(player)
event:FireClient(player)
end)


Human one is The name for my remote event

0
Is the script inside a player or an NPC? youtubemasterWOW 2717 — 11mo
0
It is inside of the NPC JoePlato 5 — 11mo

0
VVoretex 146
11 months ago

You could try to check the Humanoids health instead of the function. Such as:

local hum = --your humanoid

if hum.Health == 0 then --checks if the Humanoid's health is 0
event:FireClient(player)
end)


I hope this helped c:

0
The calling of the player needs to first be definded in the function so it is not working because it does not know how to fire JoePlato 5 — 11mo
0
Filipalla 504
11 months ago
Edited 11 months ago

Humanoid.Died does not pass the Player

Humanoid.Died

0
Does that mean that I need to not just do the event of it dying but having to reference the propertie of its health instead JoePlato 5 — 11mo
0
One way of doing it is to have a creator tag(ObjectValue with the Player as value) created when a Player damages it and get the killer from that Filipalla 504 — 11mo
0
Another way is storing all Players that have dealt damage to it in a table(Probably above your skill level though) Filipalla 504 — 11mo
0
How would I do that?  JoePlato 5 — 11mo
0
https://devforum.roblox.com/t/how-do-i-confirm-a-kill-consistently/328295/2?u=filipalla This is how you would use the creator tag method Filipalla 504 — 11mo
0
The setting the object value with the player as the value JoePlato 5 — 11mo
0
In all thingys that deal damage get the Player using it and create an ObjectValue with Instance.new then set ObjectValue.Value = Player Filipalla 504 — 11mo
0
also, set the Name to creator or whatever name you want to use for it Filipalla 504 — 11mo
0

Store a script inside a humanoid. I'm assuming that you want to do something on the server's side so instead of using a remote event to fire a client, use a Bindable Event. Bindable Events are basically remote events, but for two servers talking to each other. You will also need to use a .Changed event too. If you want to use a remote event, then do the same thing in this script, but with a remote event. TIP: You can use a BindableEvent in the same script.

script.Parent.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
BindableEvent:Fire()
end)

BindableEvent.Event:Connect(function()
-- Event
end)

0
I meant to say character! Sorry! TribotGamerGX 169 — 11mo
0
It is not working Bc I need to fire a remote event to a local script(hence why it needs to be a remote event) JoePlato 5 — 11mo