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 4 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?

01local y = nil
02_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)
03if material == Enum.Material.Air and not y then
04    y = hum.RootPart.Y
05end
06if y and material ~= Enum.Material.Air then
07local newy = hum.RootPart.Y
08local diff = math.abs(newy-y) - 10
09if diff < 10 then diff = 0 end
10hum:TakeDamage(diff)
11print("Damage taken: "..tostring(diff))
12y = nil
13end
14end)
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 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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

01_G.Changed = function(part, PropertyName, func)
02    local current = part[PropertyName]
03    coroutine.resume(coroutine.create(function()
04        while true do
05            repeat game.RunService.RenderStepped:wait() until part[PropertyName] ~= current
06            coroutine.resume(coroutine.create(function()
07            func(part[PropertyName], current, part)
08            end))
09            current = part[PropertyName]
10    end
11    end))
12end
Ad

Answer this question