Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Negating a fall damage script when you touch a certain part?

Asked by 4 years ago

I have a fall damage script, and I want it to not do damage if you hit a part that's inside a folder.

I do have a way to negate it already, but it delays the damage from happening for like 3 seconds, and I think that it looks sloppy to have it delayed that much.

my script right now is as follows :

local HeightRequired = 10
local DamageScale = 2.5 
game.Players.PlayerAdded: Connect(function(Player)
    Player.CharacterAdded: Connect(function(Character)
        local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
        local Humanoid = Character:WaitForChild('Humanoid')

        local StartJump = nil

        Humanoid.FreeFalling:Connect(function(Active)
            if Active then
                StartJump = HumanoidRootPart.Position.Y
            else
                local JumpHeight = StartJump - HumanoidRootPart.Position.Y

                if JumpHeight > HeightRequired then


                        Humanoid:TakeDamage((JumpHeight - HeightRequired)*DamageScale)





                end
            end
        end)
    end)
end)

so how would I make it so you can negate the fall damage from happening when a certain part is touched?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

It is easier to stop fall damage by detecting a certain material rather than detecting if the block is in a folder. You would only need to change line 16 of your code if you can compromise:

--Insert into line 16. Replace the material with the one of your choice.
if JumpHeight > HeightRequired and Humanoid.FloorMaterial ~= Enum.Material.Fabric then
1
works fine, but using "not" doesn't work, I simply changed it from that to using ~= instead of an == gwenniekins 59 — 4y
0
Oops, I'll correct the answer HappyHammer55555 99 — 4y
Ad

Answer this question