How would I tween this?

Hello everyone! I currently have a low knowledge and would like to know, when I make my GUI visible (a panel), how would I tween the panel?

You can see my script below.

Regards,
Ach!

You can tween it using tweenservice.

Okay, that do not helps me at all… I asked a example, I am not really sure of how to use all the functions of it.

You should read about tweenservice page that roblox made.

Can you link me to it? It’s would make me mark your link the solution.

You can use TweenPosition

@RatiusRat Yes but it depends on the usecase, if it’s just to tween a frame/GuiObject, there’s no need for the flexibility

Honestly tweenservice is much more flexible that that.

Can you give me an example of how would I do so?

The Article provides an example on how you use it, it gives you all you need to understand the workings of it and how you can use it for your needs

You just need to specify the new position via an UDim2 and some other parameters like easingStyle nad Direction if needed

Okay. I marked @RatiusRat post the solution.

-- Tween Service
local TweenService = game:GetService("TweenService")

-- Tween Info
local tweenInfo = TweenInfo.new(
	2, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

-- Properties you want to change | Table
local Property = {
   Size = Vector3.new(),
   Transparency = 1,
   -- Etc
}

-- Creating the tweenService
TweenService:Create(part_you_want_to_tween, tweenInfo, Property):Play() -- Make sure to :play() the tween

You can find more info here

Actually, with my current script, how would I do all of the things? @TheDCraft

What are you trying to tween? Transparency? Position? Both?

I am trying to tween the position, so it’s looks clean when opening it up.

Here is what I tried to do right now, not sure tho:

local button = script.Parent

local Panel = game:GetService("ReplicatedStorage").Cross.UIs.Cross.Panel

local TweenService = game:GetService("TweenService")

local TweenInformation = TweenInfo.new(
	3,
	Enum.EasingStyle.Elastic,
	Enum.EasingDirection.Out,
	-1,
	true,
	0
)

button.MouseButton1Click:Connect(function()
	if script.Parent.Text == "Open Cross" then
        TweenService:Create(Panel, TweenInformation):Play()
	elseif script.Parent.Text ~= "Open Cross" then
		script.Parent.Text = "Administrator permissions missing."
		wait(2)
		script.Parent.Text = "[Blocked]"
	end
end)

You didn’t specify the end properties, you only gave the thign to tween and the tweenInfo to use

local button = script.Parent

local Panel = game:GetService("ReplicatedStorage").Cross.UIs.Cross.Panel

local TweenService = game:GetService("TweenService")

local TweenInformation = TweenInfo.new(
	3,
	Enum.EasingStyle.Elastic,
	Enum.EasingDirection.Out,
	-1,
	true,
	0
)

local endPosition = UDim2.new(0,0,0,0) --Change the 4 0s to what you want

button.MouseButton1Click:Connect(function()
	if button.Text == "Open Cross" then
        TweenService:Create(Panel, TweenInformation,{Position = endPosition}):Play()
	else
		button.Text = "Administrator permissions missing."
		wait(2)
		button.Text = "[Blocked]"
	end
end)

@TheDCraft UDim2 not Udim2

1 Like

So what you would do is this:

local TweenService = game:GetService("TweenService")

local TweenInformation = {
   3,
   Enum.EasingStyle.Elastic,
   Enum.EasingDirection.Out,
}

button.Activated:Connect(function()
   if script.Parent.Text == "Open Cross" then
      TweenService:Create(Panel, TweenInformation, {
         Position = UDim2.fromScale(0.5,0.5) -- Assuming you want it centered
       }):Play()
   else
      -- Other code
   end
end)

@EmbatTheHybrid Sorry, I didn’t notice :sweat_smile:. Thanks

2 Likes

Thanks you! It’s work perfectly fine now, that was my first time doing tweening also, sorry if I did it in a bad way. :stuck_out_tongue:

It’s fine, there are many ways you can use TweenService, this is just the way I do it and many others I assume. Good luck :+1:

1 Like