Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't the part I want to tween moving?

I'm trying to move this model from one place to the place I want. This was the code I wrote and I tweaked it a little bit and i got it from the Roblox Wiki: (Written In A LocalScript)

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(120)
local goal = {}
goal.Position = Vector3.new(68.92, 2, -19.63)
local tween = TweenService:Create(goal, tweenInfo, script.Parent)
tween:Play()

What I wanted to do was tween a part but the duration from when it got to it's current position to the goal position would be 2 minutes. (120 seconds) I tried the code above, and it didn't move at all. What am I doing wrong??

1 comment

0

Why are you using a LocalScript? TweenService also works for Server Scripts. Also, I don't think you can move models like that since the Position property does not exist in a model.

1 answer

✓ Accepted answer

Hey there! I'm BlackOrange here to help!

First off, unfortunately, you cannot tween Models. Secondly, TweenService is only for ServerScripts

https://wiki.roblox.com/index.php/API:Class/TweenService

Now, if this was a ServerScript (Script) in a Part (Not a model), then your script would work.

Though this is a very simple fix, I do suggest better variable names like this:

local TweenService = game:GetService("TweenService")
local Part = script.Parent

local TweenTime = TweenInfo.new(120) -- since this is the time

local goal = {}
goal.Position = Vector3.new(68.92, 2, -19.63)

local CreateTween = TweenService:Create(Part, TweenTime, goal)
CreateTween:Play()

Whiling I was typing that I noticed you got 2 arguments wrong, the Object comes first in this case Part, then TweenTime then goal. Try this new script I have made and make sure it's a Script. Also make sure the part isn't already in the position 68.92,2,-19.63 or you won't see anything happenings.

Hopefully this helped! Best of luck!

6 comments

0

Sorry @BlackOrange3343, it didn't work. I wrote that code in a ServerScript (Script) and the part that has the script child didn't budge. I switched the time to 2 seconds, still didn't budge. I put the script in a separate part and it still didn't budge. Help please! :(

0

@BlackOrange3343 is correct, the script does work. I tested it out myself, make sure it's a Server Script, and it's inside of the part. @Chez_Guy

0

@BlackOrange3343 TweenService isn't only a server-only service, it can also be used in localscripts.

0

@op nothing's wrong with this script, unless you parented the script to a place where it can't work or probably you kept the part at the position you're attempting to tween the part to

0

Well guess what? Stupid me left the Script disabled. After my many minutes of rage, I enabled it and it worked! Thank you so much Orange!!

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.