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

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

Asked by 3 years ago
Edited by youtubemasterWOW 3 years 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 2741 — 3y
0
It is inside of the NPC ExecutiveJoe 5 — 3y

3 answers

Log in to vote
0
Answered by
VVoretex 146
3 years 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 ExecutiveJoe 5 — 3y
Ad
Log in to vote
0
Answered by
Filipalla 504 Moderation Voter
3 years ago
Edited 3 years 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 ExecutiveJoe 5 — 3y
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 — 3y
0
Another way is storing all Players that have dealt damage to it in a table(Probably above your skill level though) Filipalla 504 — 3y
0
How would I do that?  ExecutiveJoe 5 — 3y
View all comments (4 more)
0
0
The setting the object value with the player as the value ExecutiveJoe 5 — 3y
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 — 3y
0
also, set the Name to creator or whatever name you want to use for it Filipalla 504 — 3y
Log in to vote
0
Answered by 3 years ago

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 184 — 3y
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) ExecutiveJoe 5 — 3y

Answer this question