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.
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.
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 .
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