Troubles with tweening!

Hello! I’m currently struggling to tween my part. The problem at the moment is that the model is teleporting backward then smoothly going into the position they are currently set at in studio., whereas I want it to go forward into the tunnel As seen in this gif!

Script:

local tweenservice = game:GetService("TweenService")
local info = TweenInfo.new(5)
local bot = script.Model.PrimaryPart
local goals = {
	   Position =  bot.Position - Vector3.new(90,0,0)
	}

local model = tweenservice:Create(script.Model.PrimaryPart,info,goals)


while true do
	model:Play()
	wait(5)
	script.Model.PrimaryPart.Position = Vector3.new(8.449, 5.176, -125.873)
end

(As you can see I’m not very experienced with tweening/positions.)

You put it in a while loop, so all the script did was repeat the tween you created after 5 seconds. If you don’t want that, remove the loop or have the loop run after the tween is completed with this line:

model.Completed:Wait()

I want it to loop so I can see it. But would you know why it goes behind the wall instead of forwards?

Because you set the position of the model back to where it originally was, as well as repeat the tween. That’s also as far as the tween went. You’ll need to fix the end position for the tween if you want it to go further.

Oh! How could I do an end position? Since what I’m trying to do is make it go forward, then teleport back to its original spot.

Modify what you had on line 5, with:
Position = bot.Position - Vector3.new(90,0,0)
and increase the X value in the Vector3 constructor.

On a more off-topic note, I would use CFrame instead of position. It’s a much better practice and offers a lot more flexibility with positioning and angling.

How can I switch to CFrame and could you clarify what you mean by increase the X in the Vector3 constructor!
(Sorry with all the questions not that good at this stuff.)

By “increase the X value in the Vector3 constructor”, I mean increase the first argument you gave in Vector3.new(), which is where the number 90 is. Vectors are comprised of 3 axes: X, Y and Z. They are always in that order, which is why 90 is of the X axis. So by increase, all I mean is to raise the value of 90.

To convert from Vector3 to CFrame, just replace “Position” with “CFrame” on line 5. Then, just do this for line 5:
CFrame = bot.CFrame * CFrame.new(90, 0, 0)
Replace 90 with your new value for the X axis as well if you want it to go into the tunnel.

Thanks you soo much! Your an acutal life saver! Not sure what caused it to go backwards but you fixed it! I appreciate the help alot!