****so im making a game where once u beat the final boss a cutscene will play but i dont know how to check if the npc boss is dead. I tried if script.Parent.Humanoid.Health == 0 then
--- play the cutscene
end
but it doesnt work. help?****
This should work, I'm pretty sure the died function isn't deprecated.
1 | local character = script.Parent |
2 | character:WaitForChild( "Humanoid" ).Died:Connect( function () |
3 | print (character.Name .. " has died!" ) |
4 | end ) |
You need to use HUMANOID.Died
here is page on wiki: Humanoid.Died - Wiki
Here is a example:
1 | local npc_humanID = script.Parent:WaitForChild( "Humanoid" ) |
2 |
3 | npc_humanID.Died:Connect( function () |
4 | print ( "The npc " .. script.Parent.Name .. " died!" ) |
5 | end ) |
for play cutscene:
01 | local npc_humanID = script.Parent:WaitForChild( "Humanoid" ) |
02 |
03 | npc_humanID.Died:Connect( function () |
04 | local cutscene = game:GetService( "ReplicatedStorage" ).Cutscene -- Cutscene Location |
05 | for i,v in pairs (game.Players:GetPlayers()) do |
06 | if v.Character ~ = nil then |
07 | cutscene:Clone().Parent = v.Character |
08 | end |
09 | end |
10 | end ) |
Hope it helped :)
Errors? tell-me on comments.