I want it to not deal damage while you are ragdolled, the ragdoll doesn’t have any takedamage in it so I’m confused.
Here is the script:
task.wait(1)
script.Parent = script.Parent.Humanoid
local lowestFallHeight = math.random(18,25)
local maxFallHeight = math.random(70,135)
local humanoid = script.Parent
local torsotype = humanoid.Parent
local torso
local isFalling = false
local deb = false
if humanoid.RigType == Enum.HumanoidRigType.R6 then
torso = torsotype.Torso
else
torso = torsotype.UpperTorso
end
local module = require(game:GetService('ReplicatedStorage').RagdollModule)
local debounce
humanoid.FreeFalling:connect(function(falling)
isFalling = falling
if isFalling and not deb then
deb = true
local maxHeight, lowHeight = 0, math.huge
while isFalling do
local height = torso.Position.y
if height > maxHeight then
maxHeight = height
end
if height < lowHeight then
lowHeight = height
end
task.wait()
end
local fallHeight = maxHeight - lowHeight
local impactHeight = fallHeight - lowestFallHeight
if impactHeight > 0 then
if not debounce then
debounce = true
local damage = impactHeight * (humanoid.Health / maxFallHeight) * 5
humanoid:TakeDamage(damage)
print('Player damaged' .. damage)
if humanoid.Health > 0 then
game:GetService('ReplicatedStorage').Events.FallDamageRagdoll:FireServer()
end
task.wait(6)
debounce = false
end
end
deb = false
end
end)