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

Help with making a bouncy character script *without* creating instances?

Asked by 11 months ago
Edited 11 months ago

So basically, with this script I either bounce little to none at all or way too much from large enough heights, what can I do?

local Changed = function(part, PropertyName, func)
    local current = part[PropertyName]
    local elapsedTime = 0

    coroutine.resume(coroutine.create(function()
        while true do
            repeat elapsedTime = elapsedTime + task.wait() until part[PropertyName] ~= current

            local v,v2 = coroutine.resume(coroutine.create(function()
                return func(part[PropertyName], current, elapsedTime)
            end))

            if v2 == "stop" then break end
            elapsedTime = 0
            current = part[PropertyName]
        end
    end))

end
local y = 0
local hum = game.Players.LocalPlayer.Character.Humanoid
Changed(hum.RootPart, "CFrame", function(cf)
    if cf.Y > y then
        y = cf.Y
    end
end)

Changed(hum, "FloorMaterial", function(mat)
    if mat ~= Enum.Material.Air then
        hum.RootPart.Velocity = Vector3.new(hum.RootPart.Velocity.X, (y-hum.RootPart.CFrame.Y), hum.RootPart.Velocity.Z) -- the "bounce" part
        y = hum.RootPart.CFrame.Y
    end
end)
0
I wanna know how to make this without instances so I can re-create this for my minecraft mod eheheh RedWirePlatinum 53 — 11mo

1 answer

Log in to vote
0
Answered by 11 months ago

Actuallyyyyyyyy... I figured it out, lol

local y = 0
local hum = game.Players.LocalPlayer.Character.Humanoid
Changed(hum.RootPart, "Velocity", function(vel)
    task.wait()
    y = vel.Y
end)

Changed(hum, "FloorMaterial", function(mat)
    if mat ~= Enum.Material.Air then
        hum.RootPart.Velocity = Vector3.new(hum.RootPart.Velocity.X, math.abs(y)*0.9, hum.RootPart.Velocity.Z) -- the "bounce" part
        y = hum.RootPart.CFrame.Y
    end
end)
Ad

Answer this question