Hello! i’m doing drowning system for my game. System uses “Humanoid.StateChanged”
everything is works fine until player got ragdolled. When player got ragdolled, drowning system not works
Video about it:
Drowning Script - (Server Script):
Humanoid.StateChanged:Connect(function(Old, New)
if New == Enum.HumanoidStateType.Swimming and Character:FindFirstChild("Head") then
Character.Stamina.Swimming.Value = true
repeat
wait()
Character.Stamina.Value -= 0.5
until Character.Stamina.Swimming.Value == false or Character.Stamina.Value <= 0
if Character.Stamina.Value <= 0 then
repeat
wait(1)
if Character.Stamina.Swimming.Value == true then
Humanoid:TakeDamage(15)
Character.Head.DrowningSound.PlaybackSpeed = math.random(90, 115) / 100
Character.Head.DrowningSound:Play()
end
until Character.Stamina.Swimming.Value == false or Humanoid.Health <= 0
end
else
Character.Stamina.Swimming.Value = false
end
end)
How can i fix this?