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

Fall damage not being taken?

Asked by 3 years ago

I wanted to try making a basic fall damage script for future purposes, but for some reason, fall damage isn't being taken. What can I do?

local y = nil
_G.Changed(game.Players.LocalPlayer.Character.Humanoid, "FloorMaterial", function(material,past,hum) -- Used a slightly different custom changed function, works like GetPropertyChangedSignal except it provides the current and previous value (the 3rd argument is just the part itself)
if material == Enum.Material.Air and not y then
    y = hum.RootPart.Y
end
if y and material ~= Enum.Material.Air then
local newy = hum.RootPart.Y
local diff = math.abs(newy-y) - 10
if diff < 10 then diff = 0 end
hum:TakeDamage(diff)
print("Damage taken: "..tostring(diff))
y = nil
end
end)
0
If you ask why I didn't just use roblox's provided changed function the answer is that I find this simpler to use (for me at least) RedWirePlatinum 53 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

the function in question, juuust in case it's needed

_G.Changed = function(part, PropertyName, func)
    local current = part[PropertyName]
    coroutine.resume(coroutine.create(function()
        while true do
            repeat game.RunService.RenderStepped:wait() until part[PropertyName] ~= current
            coroutine.resume(coroutine.create(function()
            func(part[PropertyName], current, part)
            end))
            current = part[PropertyName]
    end
    end))
end
Ad

Answer this question