how would i make a death like in mirrors edge where is fades your screen to black right before you die by falling
Have a GUI with a black frame. Make its transparency 1 and then when the death is occurring, use TweenService
also tween its transparency
yeah i know but how would i detect if the player is going to die from fall damage and fade it before they die
if Humanoid.Health - (FallDamage) <= 0 then
--(code)
end
To check if they are falling, you can detect the HumanoidStateType to see if it’s FallingDown.
If you want to get more advanced, I recommend you use a raycast to check if you want. Unless you are already to handle the fall damage.
This does work but assume they want to predict when the player is about to die, just do something like:
local DAMAGE = 10
-- 10 damage for every 5 studs fell
local FloorPos = blah blah
--[[ raycast from the
HumanoidRootPart
and set the FloorPos
as the intersection
position
]]
function calcDamage(freeFallHeight)
-- this could be the worse formula
return freeFallHeight / 10 * DAMAGE
end
if Humanoid.StateType == Enum.HumanoidStateType.Freefall and (Humanoid.Health - calcDamage((HumanoidRootPart.Position - FloorPos).Magnitude)) <= 0 then
-- play the tween
end
this is probably the most advanced math (that makes sense to me) that I’ve done in Roblox (lol)
i assume parkour reborn and the video are both just using a hitbox to detect lol.
I’m not sure if you want the tween or something else. I’m not really sure so I made the script actually sorta work
local DAMAGE = 10
-- 10 damage for every 5 studs fell
function calcDamage(freeFallHeight)
-- this could be the worse formula
return freeFallHeight / 10 * DAMAGE
end
Humanoid.StateChanged:Connect(function(oldstate, newstate)
if oldstate ~= Enum.HumanoidStateType.Freefall and newstate == Enum.HumanoidStateType.Freefall then
local FloorPos = nil
--[[ raycast from the
HumanoidRootPart
and set the FloorPos
as the intersection
position
]]
if (Humanoid.Health - calcDamage((HumanoidRootPart.Position - FloorPos).Magnitude)) <= 0 then
-- play the tween
end
end
end)