Animated part position starting at a different place

I have a ball that I have placed on the ground in Roblox Studio, and I wish to make it oscillate back and forth (jump up and down) forever. Here I used TweenService to animate its position relative to itself; first it goes up, then it goes down.

local BouncingBall = script.Parent

local tweenService = game:GetService("TweenService")

while true do
	local goalUp = {}
	goalUp.CFrame = BouncingBall.CFrame:ToWorldSpace(, 20 , 0))
	local tweenInfoUp =, Enum.EasingStyle.Bounce)
	local tweenUp = tweenService:Create(BouncingBall, tweenInfoUp, goalUp)
	local goalDown = {}
	goalDown.CFrame = BouncingBall.CFrame:ToWorldSpace(, -20, 0))
	local tweenInfoDown =, Enum.EasingStyle.Bounce)
	local tweenDown = tweenService:Create(BouncingBall, tweenInfoDown, goalDown)

However, when I start the game, for some reason the ball is doing the oscillation motion above the ground:

What is the mistake here? Why is the ball going up in the air first before doing the bounce motion?

1 Like

The tween takes 2 seconds to complete, but you are waiting only 0.5 seconds. You can replace the waits with Tween.Completed:Wait()


Thanks! I had assumed that TweenService would block the thread but didn’t realize that was not the case.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.