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

Fall damage not being taken?

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)

1 comment

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)

1 answer

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

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