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