The title says everything itself. If a player falls from a high place, and he manages to climb a truss part, the player doesn’t get any damage at all. How do I fix that?
Hello,
could you provide us your script so we are able to find out the problem that is occurring in the script and then find some way to fix that?
There.
Local script:
hum.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Landed then
local fallVelocity = -root.Velocity.Y
local CheckForFloor = Ray.new(char.HumanoidRootPart.Position, Vector3.new(0, -20, 0))
local Floor, FloorPos = workspace:FindPartOnRay(CheckForFloor, char)
wait(0.01)
if not Floor:FindFirstChild("ReduceDamage") then
if fallVelocity > 100 then
local dmg = (fallVelocity / 50) ^ 5
event2:FireServer(dmg)
print(dmg)
end
else
if fallVelocity > 100 then
local dmg = (fallVelocity / 65) ^ 5
event2:FireServer(dmg)
print(dmg)
end
end
end
end)
Server Script:
event2.OnServerEvent:Connect(function(plr, dmg)
local sound2 = sound:Clone(plr.Character.HumanoidRootPart)
sound2.Volume = 10
sound2:Play()
plr.Character.Humanoid:TakeDamage(dmg)
end)
I’m not really into the HumanoidStates, so I’m not sure if the Landed state is occurring when you start climbing a ladder right away after falling down. You might want to add or newState == Enum.HumanoidStateType.Climbing
, but I might be completely wrong here.
Hope this helped,
have a nice day.
At the first time I thought it fixed it, but it didn’t.
Now I’m looking into the script more and I see that the Raycast might not find any Floor part. That would lead into the script not giving fall damage to the player.
You could possible not check for the floor if the oldState is Enum.HumanoidStateType.Climbing
, but I’m not really sure if it is a great thing to do.
Also when I’m now thinking about adding the or newState == Enum.HumanoidStateType.Climbing
, I’m realizing that there might occur false fall damage, but I’m not sure about this.
I hope this helped,
have a nice day!