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

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

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)

1 comment

0

I wanna know how to make this without instances so I can re-create this for my minecraft mod eheheh

1 answer

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)

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