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

Why my Part is not moving correctly with Tween service?

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 -

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

local Info = TweenInfo.new(
   5,
   Enum.EasingStyle.Linear,
   Enum.EasingDirection.In,
 -1,
 true,
   0
   )


local Goals =                  
{
    Position = Vector3.new(10,0,0); -- i want it to only move the x position but i moves all of them?

}

local movepartx = TweenService:Create(part, Info, Goals)
wait(1)
movepartx:Play()

5 comments

0

put it in a code block for god sake

0

Please put a block gode in goddamnit

0

whats a code block?

0

When you press LUA icon there is two line of ~~~~ Put the code inside (not outside) that 2 time of ~~~~~

0

edit:- fixed codeblock

1 answer

✓ Accepted answer

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:

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

local Info = TweenInfo.new( 5, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1, true, 0)

local partPos = part.Position
local Goals =
{ 
	Position = partPos + Vector3.new(10,0,0)
}

local movepartx = TweenService:Create(part, Info, Goals)
wait(1)
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.

1 comment

0

sorry and i understand it better now i was exposed to add the position not set it

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