Issue with Tweening my Frame

Hello everyone!

This is my first ever Topic. I am new to scripting so I am not that good. I’m not really good at explaining to but I’ll try my best.

1. What do you want to achieve?
I want to make a script that when you click a button the frame tweens to the middle of your screen

2. What is the issue?
The issue is that when I click the button, the frame doesn’t move to the middle of the screen, but to the top left.

3. What solutions have you tried so far?
I am very bad at scripting so I searched for a tutorial how to make a tweening frame. But every time I try it it goes wrong…

It is kind of like a system as in Welcome To Bluxburg. When u click the ‘Help’ button a frame tweens to the middle of your screen.

I hope I explained good enough.

Thanks for your help!

2 Likes

Anchor Point can help with that, set it 0.5,0.5

Then do something like this.

local TweenService = game:GetService("TweenService")

TweenService:Create(Frame,TweenInfo.new(1 --[[ time till tween finishes]], {Position = Udim2.new(0.5,0,0.5,0)}):Play()
2 Likes

Thank you!

Where do I put this script?

It usually goes into a local script, but you can put it anywhere =) you just need to make sure local Frame = script.Parent.Parent.Frame exists, if It’s placed in a button to get the object.

Example:

local Button = script.Parent.Button
local Frame = script.Parent.Frame

Just need to get the exact object you’re tweening.

1 Like

Alright thanks! I already have some scripts but idk if they are correct…

I tried to set the frame it’s anchor point to 0,5,0,5 and it almost disappeared from my screen when I clicked the button.

That’s because you need to correctly position it now since it anchors to a point, 0.5,0.5 is a way to get the middle easier,

X,Y - Anchor Point

So the Y is only needed to be positioned at 0.5, you can set it to -1 for the X position to move it from the side.

local TweenService = game:GetService("TweenService")
TweenService:Create(Frame,TweenInfo.new(1),{Position = UDim2.new(x,x,y,y)}):Play()
1 Like

It moves from the bottom to the mid

Are you moving from the Y Axis?

1 Like

I’m sorry I’m very bad at scripting I’m really trying my best :frowning:

Try creating a dummy frame and set its position to that of which you are tweening to, then see if it is correct. If not, then just keep doing it until you get it right.

1 Like

No worries, I can make a simple example for you if you’d like : )

1 Like

Do you mind just sending us your script?

1 Like

As you can see the frame is on the bottom

Yep, just making it real quick for you guys to download .

1 Like

yes please, that would be super nice!

my script?

here:


its the TweenFrame script

close frame script (button inside frame that needs to be tweened)

1 Like

ExampleTweenService.rbxl (26.5 KB)
Here : ) this should help you understand, it’s actually very simple.

Code;

local TS = game:GetService("TweenService")
local on = false

script.Parent.TextButton.MouseButton1Click:Connect(function()
	if on then on = false
		TS:Create(script.Parent.Frame,TweenInfo.new(1),{Position = UDim2.new(0,0,0.5,0)}):Play()
	else on = true
		TS:Create(script.Parent.Frame,TweenInfo.new(1),{Position = UDim2.new(0.5,0,0.5,0)}):Play()
	end
end)
2 Likes

I meant @lolgamerpro456 XD. I just want to see if he had any errors and also where he is tweening to.

1 Like

That is not how your use UDim2…

1 Like

oh I’m sorry… I never used it before…
I’m dumb