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

How can i do a function on humanoid died?

Asked by 5 years ago

I'm making a remoteevent with this script and idk why it doesn't works, please help me

--This is a Script
local Event = game.ReplicatedStorage:WaitForChild("RedWin")
local Humanoid = script.Parent:WaitForChild("Humanoid")

Humanoid.Died:Connect(function()
    print("hi")
    Event:FireServer()
end)
0
Try to kill the "npc" with server. not take damage with client. only server. yHasteeD 1819 — 5y
0
try adding parameters? and change it to FireClient()??? ^_^ greatneil80 2647 — 5y
0
RemoteEvents can only be fired to the server when it's in a LocalScript. luaclifford 0 — 5y
0
Are you keeping this script in StarterCharacterScripts? OptimisticSide 199 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Try something like this, except in a LOCAL script, inside StarterPlayerScripts

local plr = game.Players.LocalPlayer
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("RedWin")

if plr.Character.Humanoid.Health == 0 then -- what to do if the health is 0
    print("hi")
    event:FireServer(plr) -- you will want to do this to let the server know which player died.
end
Ad
Log in to vote
0
Answered by 5 years ago

thanks for the help but i need this script for an npc , not a player

0
yeah sorry for necro but i need it too so did you fixed? Berta012oof 0 — 4y

Answer this question