Bounce off, how exactly?

What I want to create is an bounce off system. Once a player touches the OuterTorso of my penguin in bounces them backwards with an animation. An example for this is Adopt me’s recent update.

I’ve tried to just move the hipheight to 8 and then back to 2.1 but that doesn’t push the player backwards and a animation adding to it would be impossible because you can’t time how long the player is in the air.

Thanks for reading!

I can’t give you an exact code, but I can give you an idea how to do it.
Let’s say you got a Main_Part. Main_Part would be a simple part that player is going to touch and bounce from it.
Then add another part called Primary_Part. Now here is an idea.

Primary_Part will be a part that will create a Bouncing Path. Bouncing path will lead to a Max_Distance. Max_Distance would be a maximum distance of the Primary_Part.

Once player touches the Main_Part, players HumanoidRootPart will be welded to a Primary_Part. Primary_part should be spawned at the place where player touched the Main_Part. You will create a Bouncing Path using TweenService | Documentation - Roblox Creator Hub. When Primary_Part reaches the Max_Distance, players HumanoidRootPart will be unwelded (destroyed) and player will start falling down.

Possible Error There is a possibility that TweenService won’t let you weld any part to a tweening part (Primary_Part), if that occurs I recommend you using CFrame | Documentation - Roblox Creator Hub to create a Bouncing Path by yourself. CFrames are pretty much complicated, but if you are good at math, this wouldn’t be much of a problem.

1 Like

I’m not the best with cframed tho. Could you get into more detail with this?

Two ways you could do this:

  1. Use BodyMovers. BodyMovers can actually do a sort of bounce, like the BodyVelocity if you pull it off correctly.
  2. Manual calculation. You would have to calculate the math to create a bounce type effect, most likely using math.sin and CFraming.

I recommend applying a force to the player when they touch the penguin, using a bodyforce, and if I am not mistaken… the force you should apply to the bodyforce should be:

local BodyForce = HumanoidRootPart:FindFirstChild("BodyForce") or Instance.new("BodyForce", player:FindFirstChild("HumanoidRootPart"))
local Velocity = HumanoidRootPart.CFrame.LookVector * -anyNumber
BodyForce.Force = Velocity

If you need a full script, then you can message me on the devforum for one. Also, correct me if my script is incorrect :stuck_out_tongue: .

3 Likes

Hey, you made a typo.

HumanoidRootPart:FindFirstChild("BodyForce")

Other than that it’s good.

1 Like

If you want to bounce a player back, you can use a BodyMover (specifically a BodyVelocity, or BodyForce):

local dir = (yourHRP.Position - penguinTorso.Position).Unit
BodyVelocity.Velocity = dir * speed_Number -- if you're using bodyvelocity
BodyForce.Force = dir * high_number -- if you're using bodyforces

You could use animations for this, because you can make a part where the player stumbles over and 3 other keyframes for when they will bounce. After the stumbling over keyframe, you can freeze the animation using AdjustSpeed of the AnimTrack.

When the player hits the ground, you can readjust the speed or set the anim’s TimePosition to the time the first bounce occurs and lessen the velocity / force of the bodymover you’re moving, and repeat for the other 2 keyframes. Then you can have a keyframe for when the player gets up

Necessities:

You can look at the [See also] on the GetMarkerReachedSignal page when you scroll down to see how you can add markers

1 Like