Hello, How do i use TweenSizeAndPosition? I know how to tween for TweenSize, but how do i do it for both them being in one function?
2 Likes
Tweening is pretty simple and easy to remember, use this format for all tweening. You can use both size and position.
local NameOfTween = TweenService:Create(ItemYouWantToChange, TweenInfo.new(WhatYouWantInHere), {PropertyYouAreChanging = TheValue})
So make a table called: local goals = {}
then set everything you want in there. Make sure the property name is spelt correctly, so example
local part = workspace.part
local goals = {Position = Vector3.new(0, 5, 15), Size = Vector3.new(5, 10, 6)}
then added all together you get something like this:
local petSizeandPosition = TweenService:Create(part, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {goals})
I’m using TweenSizeAndPosition for a Gui, its different, right? The code you gave me will still help me on a different project though!
Tweeing gui is no different at all you just add Udim2.new instead of vector and use the properties, Position and Size Example:
local frame = script.Parent
local goals = {Position = Udim2.new(0.572, 0,0.789, 0), Size = Udim2.new(0.328, 0,0.501, 0)}
local guiTween= TweenService:Create(frame, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {goals})
The answers above are good, but I believe you’re specifically referring to this: GuiObject:TweenSizeAndPosition
If you’re looking to use that in specific, you can do the following:
local TweenToSize = UDim2.new(1, 0, 1, 0)
local TweenToPosition = UDim2.new(0, 0, 0, 0)
local TimeToComplete = 5
script.Parent:TweenSizeAndPosition(TweenToSize, TweenToPosition, Enum.EasingDirection.In, Enum.EasingStyle.Linear, 5)
In this example I did not use the override or callback parameters, but you can if you’d like.
2 Likes