My friend has written a script to deal fall damage based on how fast the player is falling
when the player walks up and down the slope it deals damage to the player. we have tried using print statements to debug but cant find what’s wrong. he has the script in ServerScriptService right now
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local HRP = Character["HumanoidRootPart"]
local Humanoid = Character["Humanoid"]
if HRP == nil or Humanoid == nil then return end
Thread = coroutine.wrap(function()
Humanoid.Died:Connect(function()
coroutine.yield(Thread)
end)
while true do
wait()
--print(HRP.Velocity.Y)
if HRP.Velocity.Y < 60 then
local FallStart = tick()
local TopVelocity = math.huge
repeat
wait()
if HRP.Velocity.Y < TopVelocity then
TopVelocity = HRP.Velocity.Y
--print(TopVelocity)
end
until
HRP.Velocity.Y >= 0
local FallTime = tick() - FallStart
if FallTime > 0.6 then
Humanoid:TakeDamage((10 * FallTime) + (0.25 * -TopVelocity))
end
end
end
end)()
end)
end)