Hello i wanted to make a cave and i noticed it was dark.So I had a idea of putting a spotlight inside a Part too make it brighter then I wanted to make it move back and forth in the cave in a line.
I watched a video on Tweenservice and it worked my part did move but not in a strait line forward.For some reason my Part moved forward and down but i only made it so that it should only move x.Is it heading towards something?
script -
01 | local TweenService = game:GetService( "TweenService" ) |
02 | local part = script.Parent |
03 |
04 | local Info = TweenInfo.new( |
05 | 5 , |
06 | Enum.EasingStyle.Linear, |
07 | Enum.EasingDirection.In, |
08 | - 1 , |
09 | true , |
10 | 0 |
11 | ) |
12 |
13 |
14 | local Goals = |
15 | { |
Okay, you had one problem when you were setting the goal
, you were setting the part to be positioned
as Vector3.new(10, 0, 0)
. What you need to do is add
10 studs on the X Axis
to the position it is already
in for it to work properly.
It should look like this:
01 | local TweenService = game:GetService( "TweenService" ) |
02 | local part = script.Parent |
03 |
04 | local Info = TweenInfo.new( 5 , Enum.EasingStyle.Linear, Enum.EasingDirection.In, - 1 , true , 0 ) |
05 |
06 | local partPos = part.Position |
07 | local Goals = |
08 | { |
09 | Position = partPos + Vector 3. new( 10 , 0 , 0 ) |
10 | } |
11 |
12 | local movepartx = TweenService:Create(part, Info, Goals) |
13 | wait( 1 ) |
14 | movepartx:Play() |
Note: please never post your code without being in code blocks, it's very annoying and hard to read.
I hope I helped, please let me know if you have further questions.