Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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??

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. starlebVerse 685 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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!

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! :( Chez_Guy 67 — 6y
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 killerbrenden 1537 — 6y
0
@BlackOrange3343 TweenService isn't only a server-only service, it can also be used in localscripts. Rare_tendo 3000 — 6y
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 Rare_tendo 3000 — 6y
View all comments (2 more)
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!! Chez_Guy 67 — 6y
0
np BlackOrange3343 2676 — 6y
Ad

Answer this question