Simple TweenService script not working

So I have this simple script here, to make an orb smoothly float up and down.

      local TweenService = game:GetService("TweenService")
      local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)         
      local orb = script.Parent          
      local sizeIncrease = 3          
      local floatDistance = 3          
      while true do          
          local tweenUp = TweenService:Create(orb, tweenInfo, {["Position"] = orb.Position + orb.CFrame.UpVector * floatDistance})         
          local tweenDown = TweenService:Create(orb, tweenInfo, {["Position"] = orb.Position + orb.CFrame.UpVector * -floatDistance})        
          tweenUp:Play()         
          wait(5)         
          tweenDown:Play()          
          wait(5)         
      end

It works pretty well. But for some reason, the orb floats down too far. What’s causing this? i’m confused.

One of mine …
An orb on the workspace with this script in it.

local part = script.Parent
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear ,Enum.EasingDirection.In, -1, true, 0)
local NewPosition = part.Position + Vector3.new(0, 5, 0)
local tween = TweenService:Create(part, tweenInfo, {Position = NewPosition})

tween:Play()

Mess with it a bit and you’ll find your sweet spot.

I found the problem, it was quite simple actually. The orb was going down too much because I was setting the “tweenDown” variable before the orb even went up, which made the orb go down twice as much as it was supposed to.

I just set it to the movement then set repeat and reverse on. No need for up and down.
*edit … Got yours working too and I like yours better. Drove myself crazy for a bit until I anchored it.

I think mine works fine for now

1 Like