#Fall damage script
1 messages · Page 1 of 1 (latest)
-- So basically, the problem with this is that it fires but it fires before i even touch the base plate
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local workspace = game:GetService("Workspace")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local direction = game.Workspace.Baseplate.Position - humanoidRootPart.Position
local MinimumOfDamage = 30
local dividend = 1
local max = humanoid.health / 1.07
print(max, humanoid.health)
local health = humanoid.health
humanoid.StateChanged:Connect(function(oldState, newState)
print(oldState, newState)
if newState == Enum.HumanoidStateType.Freefall then
local Result = workspace:Raycast(humanoidRootPart.Position, direction)
if Result then
print(tonumber(Result.Position))
print(Result.Instance)
print(Result.Position)
if Result.Position.Y < MinimumOfDamage then
print("Not a high fall")
else
print("Higher than MinimumOfDamage")
humanoid:TakeDamage(health / Result.Position.Y)
end
print(Result.Distance)
end
end
end)
It works and takes damage just it does it before i hit baseplate
and it doesnt take the amount of damageg needed
oh wait i think the whole time was i used position instead of distance
wait no nvm thats not why
new code
-- So basically, the problem with this is that it fires but it fires before i even touch the base plate
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local workspace = game:GetService("Workspace")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local direction = game.Workspace.Baseplate.Position - humanoidRootPart.Position
local MinimumOfDamage = 10
local dividend = 1
local max = humanoid.health / 1.07
print(max, humanoid.health)
local health = humanoid.health
local leftfoot = character.LeftFoot
local multiplierOfDamage = 6
humanoid.StateChanged:Connect(function(oldState, newState)
print(oldState, newState)
if newState == Enum.HumanoidStateType.Freefall then
local Result = workspace:Raycast(leftfoot.Position, direction)
if Result then
print(tonumber(Result.Position))
print(Result.Instance)
print(Result.Position)
print(Result.Distance)
if Result.Distance < MinimumOfDamage then
print("Not a high fall")
else
local distance = Result.Distance
print(distance)
print("Higher than MinimumOfDamage")
print("High fall.")
print("landed")
print(Result.Instance)
humanoid:TakeDamage(health / distance * 9)
end
end
end
end)
Ill try to fix after school
@pallid wadi how delayed it is
Why do u even feel the need to use raycasts
Just use HumanoidRootPart.AssemblyLinearVelocity
See if the speed of falling down in Y axis exceeds ur limits
And then damage the humanoid accordingly
from my experience I suggest you stay entirely away from humanoidStates they are not reliable ESPECIALLY with ragdolls and platformStand ur better off just using raycasts that check every server frame honestly. I could be wrong but its worked for me
calculate the max jump distance divide it by the distance to the ground and add the initial y position, detect a jump in the local script with uis
use humanodi states
when freefall ends
or calculate fall on client and send to server
theres lag
what
You do not know how little i understood
@tender linden
Yeah use raycast
Then
But if u have a baseplate and u need to check info about the jump you can do some math
use humanoid state landed
** You are now Level 11! **