Fall Damage based on Velocity

Hey everybody!
How would i go about making a fall damage based on velocity

I know how to use Velocity.Y or Velocity.Magnitude but not in Fall damage Context How would i do this?

1 Like

Could you possibly make a variable for the damage that is = to the players y velocity?

1 Like

Yes but im not sure how to really make a fall damage

1 Like

fallTime = 0
while true do
x = wait()
if script.Parent.Torso.Velocity.Y <= -10 then --Finds whether or not the player has begun falling and starts a timer
fallTime = fallTime + x
end
if script.Parent.Torso.Velocity.Y > -10 then --Finds when the player has stopped falling
if fallTime >= 0.4 then --Finds whether or not the player has been falling long enough to take damage
script.Parent.Humanoid:TakeDamage(fallTime * 50) --Deals damage directly proportional to falling time; can simply change the 50 to another factor balance it differently
end
fallTime = 0
end
end

This is an example code that uses the players velocity.

3 Likes
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()
				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
						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)
7 Likes

Hi! Just wondering if you could clarify on what you mean by “fall damage based on velocity”!

Do you mean that if I fall and hit the ground at a certain velocity, I will take a certain amount of damage independent of the velocity?

Or that if I fall and hit the ground based on certain factors (air time for instance), I will take a certain amount of damage that is calculated based on the velocity just before I hit the ground?

Either way, I would refer you to this lovely article that might have information on this topic: https://devforum.roblox.com/t/best-way-to-make-fall-damage/507182

2 Likes

the higher velocity there is the more dmg

1 Like