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

could someone explain to me how this script that uses Tween Service works?

could someone explain this script to me? How does 'Tweeninfo new' and its variables work. I wanted to understand better


local TweenService = game:GetService("TweenService")
	 
	local partToMove = script.Parent
	local originalCFrame = partToMove.CFrame
	 
	local tweenInfo = TweenInfo.new(
	    2,
	    Enum.EasingStyle.Linear
	    Enum.EasingDirection.Out, 
	    -1, 
	    true,
	    0 
	)
	 
	local goal = {
	    CFrame = originalCFrame * CFrame.new(3, 0, 0)
	}
	 
	local tween = TweenService:Create(partToMove, tweenInfo, goal)
	tween:Play()

1 comment

0

and how does 'Enum' work?

1 answer

Alright, I think this is how they work.

The first one is the length of the Tween.

EasingStyle is how it moves. Linear goes pretty smooth, Elastic goes pretty crazy, Bounce is of course bouncy, and there's alot more EasingStyles.

EasingDirection is how it goes. According to the Roblox Developer wiki, In is pretty slow, and out is pretty fast. And InOut is like medium speed.

The third one is how much times it loops. -1 will do it infinitely.

The fourth one is Reverse. If it's set to true, it will do the same thing again but the opposite.

The fifth one is the delay time.

By the way, I watched DevKing's tutorial on TweenService and he said you need to add a wait() before you Tween so it can work.

2 comments

0

and how does 'Enum' work?

0

Enum = table stores useful variables((Like keycodes)) but it is global. https://developer.roblox.com/en-us/articles/Enumeration

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