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()
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.