basically, once the players health is above 16 the animation should play, once, but instead it loops infinitely
here is the script:
Hm.HealthChanged:Connect(function(health)
if health >= 16 then
GettingUpAnim:Play()
local PlayerParts = Character:GetDescendants()
if Ragdolling.Value == true then
for i,M6DBSC in pairs(PlayerParts) do
if M6DBSC:IsA(SocketType) then
M6DBSC:Destroy()
elseif M6DBSC:IsA("Motor6D") then
local parent = parents[M6DBSC.Name]
if parent then
M6DBSC.Parent = parent
end
wait()
M6DBSC.DesiredAngle = Vector3.new(0, 0, 0)
M6DBSC.DesiredAngle = 0
M6DBSC.Enabled = true
end
end
parents = {}
HmHRP.CanCollide = true
game.Workspace.CurrentCamera.CameraSubject = Character.Humanoid
Hm:ChangeState(Enum.HumanoidStateType.GettingUp)
Ragdolling.Value = false
end
end
end)
This function runs every time the player’s health changes, so as the player’s health increases the animation will be played every time. Maybe try adding a debounce.
Does the animation stop playing after the player gets full health? This would confirm that.
local oldHealth = 100
Hm.HealthChanged:Connect(function(health)
if oldHealth < 16 and health >= 16 then
GettingUpAnim:Play()
local PlayerParts = Character:GetDescendants()
if Ragdolling.Value == true then
for i,M6DBSC in pairs(PlayerParts) do
if M6DBSC:IsA(SocketType) then
M6DBSC:Destroy()
elseif M6DBSC:IsA("Motor6D") then
local parent = parents[M6DBSC.Name]
if parent then
M6DBSC.Parent = parent
end
wait()
M6DBSC.DesiredAngle = Vector3.new(0, 0, 0)
M6DBSC.DesiredAngle = 0
M6DBSC.Enabled = true
end
end
parents = {}
HmHRP.CanCollide = true
game.Workspace.CurrentCamera.CameraSubject = Character.Humanoid
Hm:ChangeState(Enum.HumanoidStateType.GettingUp)
Ragdolling.Value = false
end
end
oldHealth = health
end)
The animation would only play if the previous value of health is less than 16, but the new value is greater than or equal to 16.
i̶ ̶k̶n̶e̶w̶ ̶t̶h̶i̶s̶ ̶w̶o̶u̶l̶d̶ ̶h̶a̶p̶p̶e̶n̶ that breaks the script, the player doesnt get up once health is >= 16, which means the animation wont play
maybe add a value, check if the value is true before getting up, then set it to false?
local Downed = false --this would later get changed to True once the player is downed
Hm.HealthChanged:Connect(function(health)
if health >= 16 and Downed then
Downed = false
GettingUpAnim:Play()
--rest of code
the ragdolled value already exist and its found here:
Hm.HealthChanged:Connect(function(health)
if health >= 16 then
GettingUpAnim:Play()
local PlayerParts = Character:GetDescendants()
if Ragdolling.Value == true then
for i,M6DBSC in pairs(PlayerParts) do
if M6DBSC:IsA(SocketType) then
M6DBSC:Destroy()
elseif M6DBSC:IsA("Motor6D") then
local parent = parents[M6DBSC.Name]
if parent then
M6DBSC.Parent = parent
end
wait()
M6DBSC.DesiredAngle = Vector3.new(0, 0, 0)
M6DBSC.DesiredAngle = 0
M6DBSC.Enabled = true
end
end
parents = {}
HmHRP.CanCollide = true
game.Workspace.CurrentCamera.CameraSubject = Character.Humanoid
Hm:ChangeState(Enum.HumanoidStateType.GettingUp)
Ragdolling.Value = false --right here is where its used
end
end
end)
yeah I noticed it, but you should put it next to if health >= 16 then, not make a different if statement in the first if statement
It’s the reason why the animation is playing infinitely
Try this:
Hm.HealthChanged:Connect(function(health)
if health >= 16 and Ragdolling.Value == true then
Ragdolling.Value = false --Put it first so it prevents animation playing infinitely
GettingUpAnim:Play()
local PlayerParts = Character:GetDescendants()
for i,M6DBSC in pairs(PlayerParts) do
if M6DBSC:IsA(SocketType) then
M6DBSC:Destroy()
elseif M6DBSC:IsA("Motor6D") then
local parent = parents[M6DBSC.Name]
if parent then
M6DBSC.Parent = parent
end
wait()
M6DBSC.DesiredAngle = Vector3.new(0, 0, 0)
M6DBSC.DesiredAngle = 0
M6DBSC.Enabled = true
end
end
parents = {}
HmHRP.CanCollide = true
game.Workspace.CurrentCamera.CameraSubject = Character.Humanoid
Hm:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end)