So, I’m working on BloodLine - Alpha. for a long time. And, BloodLine - Alpha. contains a script that detect if a Character limb or Dummy limb is missing, plays an animation if it is and make the Dummy or Player take damage.
BUUUUT, there’s a problem. I have a pain sound system [ if the Dummy / Player took damage, a random pain sound plays. ], when the character health is 0 or negative, the Player / Dummy continue taking damage. I think the problem here is the while wait() do thing.
I already tried using:
if Humanoid.Health == 0 then
break
end
but without sucess.
Here is my code:
local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local LeglessAnimation = Instance.new('Animation', Character)
LeglessAnimation.AnimationId = 'rbxassetid://6647735141'
LeglessAnimation.Name = 'LeglessAnimation'
local RightArmlessAnimation = Instance.new('Animation', Character)
RightArmlessAnimation.AnimationId = 'rbxassetid://6648089444'
RightArmlessAnimation.Name = 'RightArmlessAnimation'
local LeftArmlessAnimation = Instance.new('Animation', Character)
LeftArmlessAnimation.AnimationId = 'rbxassetid://6648097505'
LeftArmlessAnimation.Name = 'LeftArmlessAnimation'
local Track01
local Track02
local Track03
while wait() do
if Humanoid.Health == 0 then
break
end
if not Character:FindFirstChild('Left Leg') and not Character:FindFirstChild('Right Leg') then
Track01 = Humanoid:LoadAnimation(LeglessAnimation)
Track01.Looped = true
Track01:Play()
Humanoid.WalkSpeed = 2.5
Humanoid.JumpPower = 0
Humanoid.HipHeight = 2
Character.CrouchSystem.Disabled = true
Character.DashSystem.Disabled = true
Character.DoubleJumpSystem.Disabled = true
Character.SprintSystem.Disabled = true
while wait() do
if Humanoid.MoveDirection.Magnitude > 0 then
Track01:AdjustSpeed(1)
else
Track01:AdjustSpeed(0)
end
Humanoid:TakeDamage(1)
end
end
if not Character:FindFirstChild('Right Arm') then
Track02 = Humanoid:LoadAnimation(RightArmlessAnimation)
Track02.Looped = true
Track02:Play()
Humanoid.WalkSpeed = 13
Humanoid.JumpPower = 25
while wait(0.1) do
Humanoid:TakeDamage(1)
end
end
if not Character:FindFirstChild('Left Arm') then
Track03 = Humanoid:LoadAnimation(LeftArmlessAnimation)
Track03.Looped = true
Track03:Play()
Humanoid.WalkSpeed = 13
Humanoid.JumpPower = 25
while wait(0.1) do
Humanoid:TakeDamage(1)
end
end
end
So your problem is that when the health is >= 0, the sound plays over and over and over again? I can try to prepare a script for you that may fix this once I find out what is going on.
When you lose your right arm / left arm / legs, you start taking damage.
And it won’t stop, I already tried using break to stop the script when the player health is 0, but it’s not working.
local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')
local R6limbs = {'Right Arm', 'Left Arm', 'Right Leg', 'Left Leg'}
local LeglessAnimation = Instance.new('Animation', Character)
LeglessAnimation.AnimationId = 'rbxassetid://6647735141'
LeglessAnimation.Name = 'LeglessAnimation'
local RightArmlessAnimation = Instance.new('Animation', Character)
RightArmlessAnimation.AnimationId = 'rbxassetid://6648089444'
RightArmlessAnimation.Name = 'RightArmlessAnimation'
local LeftArmlessAnimation = Instance.new('Animation', Character)
LeftArmlessAnimation.AnimationId = 'rbxassetid://6648097505'
LeftArmlessAnimation.Name = 'LeftArmlessAnimation'
local Track01
local Track02
local Track03
Character.ChildRemoved:Connect(function(child)
if(table.find(R6limbs, child.Name)) then
Humanoid:TakeDamage(1)
end
end)
So onto what I changed…
I got rid of the while loop, and replaced it with a ChildRemoved event. So what a ChildRemoved event is, is when a child of an object gets deleted, the event fires. Then I created a table of the R6 limbs you want to check for.
Tell me if I messed up any functionality of the script, or if it didn’t fix it.
Thanks man, that worked. I just modified the Script to play animations, give damage, etc.
Here’s the modified Script:
Also, I’ll give you credits in the game description if you want.
--//Character and Descendants\\--
local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')
--//Animations\\--
----//Legless Animation\\----
local LeglessAnimation = Instance.new('Animation', Character)
LeglessAnimation.AnimationId = 'rbxassetid://6647735141'
LeglessAnimation.Name = 'LeglessAnimation'
----//Right Armless Animation\\----
local RightArmlessAnimation = Instance.new('Animation', Character)
RightArmlessAnimation.AnimationId = 'rbxassetid://6648089444'
RightArmlessAnimation.Name = 'RightArmlessAnimation'
----//Left Armless Animation\\----
local LeftArmlessAnimation = Instance.new('Animation', Character)
LeftArmlessAnimation.AnimationId = 'rbxassetid://6648097505'
LeftArmlessAnimation.Name = 'LeftArmlessAnimation'
--//Load Animations\\--
----//Load Right Armless Animation\\----
local LoadRightArmless = Humanoid:LoadAnimation(RightArmlessAnimation)
LoadRightArmless.Looped = true
----//Load Left Armless Animation\\----
local LoadLeftArmless = Humanoid:LoadAnimation(LeftArmlessAnimation)
LoadLeftArmless.Looped = true
----//Load Legless Animation\\----
local LoadLegless = Humanoid:LoadAnimation(LeglessAnimation)
LoadLegless.Looped = true
--//Tables\\--
----//Legless Table\\----
local LegsLimbs = {'Right Leg', 'Left Leg'}
----//Right Armless Table\\----
local RightArmLimbs = {'Right Arm'}
----//Left Armless Table\\----
local LeftArmLimbs = {'Left Arm'}
--//Scripting\\--
Character.ChildRemoved:Connect(function(ChildRemoved)
if (table.find(LeftArmLimbs, ChildRemoved.Name )) then
LoadLeftArmless:Play()
while wait() do
if Humanoid.Health <= 0 then
break
end
Humanoid:TakeDamage(1)
end
elseif (table.find(RightArmLimbs, ChildRemoved.Name )) then
LoadRightArmless:Play()
while wait() do
if Humanoid.Health <= 0 then
break
end
Humanoid:TakeDamage(1)
end
elseif (table.find(LegsLimbs, ChildRemoved.Name)) then
LoadLegless:Play()
while wait() do
if Humanoid.Health <= 0 then
break
end
Humanoid:TakeDamage(1)
if Humanoid.MoveDirection.Magnitude > 1 then
LoadLegless:AdjustSpeed(1)
else
LoadLegless:AdjustSpeed(0)
end
end
end
end)