soo i wanted to make Custom npc when dead but ti doesnt work
i’ve tried changing from health change to 0, or if humanoid.died , still didnt work
local Humanoid = script.Parent.Parent.Parent.Parent.Humanoid
Humanoid.HealthChanged:Connect(function(Health)
if Health <= 0 then
print("Died")
--thigs thatll happen
end
end)
yes i just wanted the animation to rotate an image from the torso
local TweenService = game:GetService("TweenService")
local humanoid = script.Parent.Parent.Parent.Parent:FindFirstChildOfClass("Humanoid")
local torso = humanoid and humanoid.Parent:FindFirstChild("Torso")
local billboardGui = torso and torso:FindFirstChildOfClass("BillboardGui")
local img = billboardGui and billboardGui:FindFirstChildOfClass("ImageLabel")
if humanoid and img then
humanoid.HealthChanged:Connect(function(health)
if health <= 0 then
print("Died")
local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local tween = TweenService:Create(img, tweenInfo, { Rotation = 90 })
tween:Play()
end
end)
else
warn("Required objects not found.")
end
local Humanoid = script.Parent.Parent.Parent.Parent.Humanoid
if Humanoid then
Humanoid.Died:Connect(function()
print("Died")
-- things that'll happen
end)
else
warn("Humanoid not found in the parent hierarchy")
end
Buddy use this script inside the rig and it will work:
local humanoid = script.Parent.Humanoid
script.Parent.Humanoid.Died:Connect(function()
print("Rig died")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://123"--Your animation ID here
animation:Destroy()
local specialMoveTrack = humanoid.Animator:LoadAnimation(animation)
specialMoveTrack:Play()
end)
smh its like when healthchange = 0, it immediately destroys the model/parent, there is no delay like 10 seconds before destroying the model, after healthchange 0 or humanoid.Died
But the rig shouldnt be destroyed its justs dies… If the problem you are facing is the rig parts falling apart just go to the rig humanoid and deactivate BreakJointsOnDeath.
here is some more prints and warns added to your script tell me whats not printing.
local TweenService = game:GetService("TweenService")
local humanoid = script.Parent.Parent.Parent.Parent:FindFirstChildOfClass("Humanoid")
local torso = humanoid and humanoid.Parent:FindFirstChild("Torso")
local billboardGui = torso and torso:FindFirstChildOfClass("BillboardGui")
local img = billboardGui and billboardGui:FindFirstChildOfClass("ImageLabel")
if humanoid and img then
print("Objects found, starting monitoring")
humanoid.HealthChanged:Connect(function(health)
print("Health changed to", health)
if health <= 0 then
print("Died")
if img.Rotation then
local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local tween = TweenService:Create(img, tweenInfo, { Rotation = 90 })
tween:Play()
print("Tween started")
else
warn("Image label does not have Rotation property")
end
end
end)
else
warn("Required objects not found.")
end