How do I tween a model up and down?

For the past hour I’ve been trying to figure out how to tween a model up and down. But I keep running into tutorials about how to tween a model to the side but I don’t want that. And I’ve also been trying to figure it out myself by messing around with the script but that also doesn’t work. Any help?

You should be able to make some modifications to the code that you are using to tween the model from side to side, as you can tween the position along a different axis to make it tween in a different direction. Could you provide the code you’re currently using to achieve the tweening from side to side?

local TweenService = game:GetService("TweenService")

local Present = workspace.BluePresent

local PresentRoot = Present.PrimaryPart

local UpInfo = TweenInfo.new()

local PresentUp = TweenService:Create(PresentRoot, UpInfo, {

CFrame = PresentRoot.CFrame * CFrame.new(PresentRoot.Size.Z + 0.1, 0, 0)

})

local PresentDown = TweenService:Create(PresentRoot, UpInfo, {

CFrame = PresentRoot.CFrame * CFrame.new(PresentRoot.Size.X + 0.1, 0, 0)

})

while true do

PresentUp:Play()

wait(1)

PresentDown:Play()

wait(1)

end

The code below uses the same method as your already working code, but it should tween it along the Y axis this time. For the PresentDown tween, you may want to change it to PresentRoot.Size.Y - 0.1. It doesn’t look extremely smooth, but it does give the same effect as when it’s moving side to side with the code provided.

local TweenService = game:GetService("TweenService")
local Present = workspace.BluePresent
local PresentRoot = Present.PrimaryPart
local UpInfo = TweenInfo.new()

local PresentUp = TweenService:Create(PresentRoot, UpInfo, {
CFrame = PresentRoot.CFrame * CFrame.new(0, PresentRoot.Size.Y + 0.1, 0)
})

local PresentDown = TweenService:Create(PresentRoot, UpInfo, {CFrame = PresentRoot.CFrame * CFrame.new(0, PresentRoot.Size.Y + 0.1, 0)
})

while true do
    PresentUp:Play()
    wait(1)
    PresentDown:Play()
    wait(1)
end

So I just tested out the script and the tweening looks really bad. And the model keeps teleporting instead of tweening:

Try making the line:

local PresentDown = TweenService:Create(PresentRoot, UpInfo, {CFrame = PresentRoot.CFrame * CFrame.new(0, PresentRoot.Size.Y + 0.1, 0)})

Changed to:

local PresentDown = TweenService:Create(PresentRoot, UpInfo, {CFrame = PresentRoot.CFrame * CFrame.new(0, PresentRoot.Size.Y - 0.1, 0)})

This will hopefully allow it to tween back down again.

This didn’t help me at all. It’s just doing the same thing.

Apologies, I was making the wrong part negative. If you make the Size of the PrimaryPart negative, then the part will tween down in the PresentDown tween. I’ve provided the complete code below.

local TweenService = game:GetService("TweenService")
local PresentRoot = workspace.Part
local UpInfo = TweenInfo.new()

local PresentUp = TweenService:Create(PresentRoot, UpInfo, {
CFrame = PresentRoot.CFrame * CFrame.new(0, PresentRoot.Size.Y + 0.1, 0)
})

local PresentDown = TweenService:Create(PresentRoot, UpInfo, {
CFrame = PresentRoot.CFrame * CFrame.new(0, -(PresentRoot.Size.Y) + 0.1, 0)
})

while true do
    PresentUp:Play()
    wait(1)
    PresentDown:Play()
    wait(1)
end
1 Like

It works I guess. It still teleports but, oh well I guess.

Are you sure it’s not just lag that’s making it appear like it’s teleporting? I tried this with the exact same code on a part in my game and it works properly.

I doubt it’s lag. I have a really good computer and really good internet and I’m getting this result:


And my CPU stays at 9% every time I run it.

1 Like

I found the problem make sure it’s anchored

4 Likes