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

How do I use TweenService with the code I made?

Asked by 5 years ago
Edited 5 years ago

Hello, I made this code... but there is one problem is that it looks like it is teleporting from stud to stud, and I am trying to make it's movement smoother. But however, I don't know how to do that, Here is the code I made.

01while true do
02 wait(3)
03wait()
04 for i = 1,90 do
05 script.Parent.CFrame = CFrame.new(script.Parent.Position + Vector3.new(.5,0,0))
06 wait()
07 end
08wait(3)
09 for i = 1,90 do
10 script.Parent.CFrame = CFrame.new(script.Parent.Position - Vector3.new(.5,0,0))
11 wait()
12 end
13end

Also, the purpose of the script is to make the part move from location to location. If anyone can solve this problem, it would be appreciated.

1 answer

Log in to vote
2
Answered by
St_vnC 330 Moderation Voter
5 years ago

Try :

01local TweenService = game:GetService("TweenService")
02 
03local part = script.Parent
04 
05local tweenInfo = TweenInfo.new(
06    2, -- Time
07    Enum.EasingStyle.Linear, -- EasingStyle
08    Enum.EasingDirection.Out, -- EasingDirection
09    -1, -- RepeatCount (when less than zero the tween will loop indefinitely)
10    true, -- Reverses (tween will reverse once reaching it's goal)
11    0 -- DelayTime
12)
13 
14local tween = TweenService:Create(part, tweenInfo, {Position = Vector3.new(0, 30, 0)})
15 
16tween:Play()

From the wiki

Ad

Answer this question