Now this is different from the last one I made. This is my script:
unit = 0.5 --Seconds
damageperunit = 1
damage = 0
game.Players.PlayerAdded:connect(function(plyr)
plyr.CharacterAdded:connect(function(char)
local h = char:FindFirstChild("Humanoid")
local hrp = char:FindFirstChild("HumanoidRootPart")
while wait(unit) do
if hrp.Velocity.Y < -1 then
damage = damage+damageperunit
else
h:TakeDamage(damage)
damage = 0
end
print(damage, hrp.Velocity.Y) --Print how much damage you will take and how fast you're moving.
end
end)
end)
As you know this script is a little glitched. If you can please fix this! Well I made a second version of this:
unit = 1
damageperunitmult = 1.5 --Change this to how much damage
damage = 0
game.Players.PlayerAdded:connect(function(plyr)
plyr.CharacterAdded:connect(function(char)
local h = char:FindFirstChild("Humanoid")
local hrp = char:FindFirstChild("HumanoidRootPart")
if h then
h.FreeFalling:connect(function()
while wait(unit) do
local speed = hrp.Velocity.Y
if speed < 0 then
damage = (speed*-1)+damageperunitmult
elseif speed > 0 then
h:TakeDamage(damage)
damage = 0
end
print(damage.." Damage and falling at "..speed)
end
end)
end
end)
Now they take 40 damage for just jumping! But some times when they fall from a tremendous height they take no damage. What is happening is that when they jump it takes less than a second so the "speed" variable doesn't have time to change. So the speed variable stays the same until one second passes.
I edited the script a little and I got this. Now they take 20 damage for walking and 40 for going up stairs. They get a lot more damage when they jump. Any help would be appreciated!
I asked this question before here. There was not much help but I edited the script and the edited script needs help!
I made a 3rd one! This one works better but I can't find the math for it. I'm trying to find the perfect amount of fall damage by Dividing. I divide it by 15 but It doesn't seem to do enough damage in some parts but seem to do too much damage at other parts.
unit = 0.5 --Seconds
damageperunit = 1
damage = 0
game.Players.PlayerAdded:connect(function(plyr)
plyr.CharacterAdded:connect(function(char)
local h = char:FindFirstChild("Humanoid")
local hrp = char:FindFirstChild("HumanoidRootPart")
while wait(unit) do
if math.floor(hrp.Velocity.y * 10^5) < 0 then
damage = damage+((hrp.Velocity.Y*-1)/20)
else
h:TakeDamage(damage)
damage = 0
end
print(damage.." Damage and falling at "..math.floor(hrp.Velocity.Y*-10^5)) --Print how much damage you will take and how fast you're moving.
end
end)
end)

4 comments
Instead of having a loop to check and see if the character is moving faster than a certain speed, you could use the FreeFalling event of a humanoid, count the number of seconds until the humanoid stops falling, and then base your damage on that time. http://wiki.roblox.com/index.php?title=API:Class/Humanoid/FreeFalling
@LightArceus , I already use that, at the time that I was making this script I didn't use it.
Are you using Velocity as a challenge or for some specific purpose?
@LightArceus , I guess a challenge, but I can use the Velocity so I can give damage depending on how fast they were.