Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

2 comments

1

works fine, but using "not" doesn't work, I simply changed it from that to using ~= instead of an ==

0

Oops, I'll correct the answer

This discussion is preserved as it was. New answers, comments, and votes are closed.