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
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)