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

How do I make an object bounce?

The game i am working on needs bouncing stuff.

1 answer

Certain size parts should bounce on their own. But, if you want a trampoline-like part, just set the Velocity property of an anchored part to something like 0, [VERTICAL VELOCITY], 0. To do it from a script (more durable; won't randomly remove the velocity when repetitively testing: part.Velocity = Vector3.new(0, vertical, 0)) The same thing can be achieved with a bouncing part after a touched event.

local part = script.Parent

part.Touched:connect(function(hit)
	local bounce = part.Velocity.magnitude -- Gets the current magnitude of the velocity.
	part.Velocity = Vector3.new(part.Velocity.x, math.abs(bounce / 2), part.Velocity.z) -- 'bounce / 2' halves the current velocity. The math.abs makes it the positive of the number (absolute), to make sure it bounces UP.
end)

This can get pretty in-depth. Very complex versions can bounce by what face hit the part. (Reflection-like bouncing)

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