I've been working on this script for a while now, it's Clonetropper1019's falling damage script, but I can't figure out how to get it to work. It's pretty cool, with the damage sound, and such. But I'd also like to make it so that if you take more than 25% of your health from falling, it'll play a sound. And if 30% or more is taken, it plays another sound. I have Half Life 2 sounds on my laptop, and I'd like to use them, but currently, I can't exactly figure out to get this script to work, nor can I figure out how to add onto script. Can someone please help me? If someone can, thanks.
local minimumFallTime = 0.75 -- ^ The minimum time the player has to fall to take damage local damagePercent = 0.5 -- ^ If its 0.5, their damage is 50% of their MaxHealth * the time they fell ---------------------------------------------------------------------------- local Humanoid = script.Parent.Humanoid local falling = false function notFreeFalling() falling = false end function FreeFalling() falling = true end Humanoid.Died:connect(notFreeFalling) Humanoid.Running:connect(notFreeFalling) Humanoid.Jumping:connect(notFreeFalling) Humanoid.Climbing:connect(notFreeFalling) Humanoid.GettingUp:connect(notFreeFalling) Humanoid.FallingDown:connect(notFreeFalling) Humanoid.Seated:connect(notFreeFalling) Humanoid.PlatformStanding:connect(notFreeFalling) Humanoid.FreeFalling:connect(FreeFalling) local hurtSound while not hurtSound do for _,v in pairs(script.Parent:WaitForChild("Head"):GetChildren()) do if v:IsA("Sound") and v.SoundId == "rbxasset://sounds/uuhhh.wav" then hurtSound = v break end end wait() end while wait() do if falling then local start = tick() repeat wait() until not falling print(tick()-start) if tick()-start >= minimumFallTime then local h,m = Humanoid.Health,Humanoid.MaxHealth local damage = (tick()-start)*(m*damagePercent) hurtSound:Play() Humanoid:TakeDamage((h<damage) and h or damage) end end end
This might work... Remember to change sound1 and sound2 into asset links... Also, Sound2 is the <70% one
local minimumFallTime = 0.75 -- ^ The minimum time the player has to fall to take damage local damagePercent = 0.5 -- ^ If its 0.5, their damage is 50% of their MaxHealth * the time they fell local sound1 = "Sound Asset ID" local sound2 = "Sound Asset ID" ---------------------------------------------------------------------------- local Humanoid = script.Parent.Humanoid local falling = false function notFreeFalling() falling = false end function FreeFalling() falling = true end Humanoid.Died:connect(notFreeFalling) Humanoid.Running:connect(notFreeFalling) Humanoid.Jumping:connect(notFreeFalling) Humanoid.Climbing:connect(notFreeFalling) Humanoid.GettingUp:connect(notFreeFalling) Humanoid.FallingDown:connect(notFreeFalling) Humanoid.Seated:connect(notFreeFalling) Humanoid.PlatformStanding:connect(notFreeFalling) Humanoid.FreeFalling:connect(FreeFalling) local hurtSound while not hurtSound do for _,v in pairs(script.Parent:WaitForChild("Head"):GetChildren()) do if v:IsA("Sound") and v.SoundId == "rbxasset://sounds/uuhhh.wav" then hurtSound = v break end end wait() end while wait() do if falling then local start = tick() repeat wait() until not falling print(tick()-start) if tick()-start >= minimumFallTime then local h,m = Humanoid.Health,Humanoid.MaxHealth local damage = (tick()-start)*(m*damagePercent) if m*0.7 > damage then sound1:Play() elseif m*0.75 > damage then sound2:Play() end Humanoid:TakeDamage((h<damage) and h or damage) end end end