I made three different frames, two with buttons. The buttons are supposed to make the third frame move towards them. Although the GUI moves, it only moves to ayy.Position, even though I clicked on the other GUI.
This is the script under one of the frames with the buttons:
01 | local plr = game:GetService( "Players" ).LocalPlayer |
02 |
03 | local gui = plr.PlayerGui:WaitForChild( "THING" ) |
04 |
05 |
06 |
07 | script.Parent.MouseButton 1 Click:Connect( function () |
08 |
09 |
10 |
11 | gui.Moving:TweenPosition(UDim 2. new(gui.ayy.Position), "Out" , 4 ) |
12 |
13 | wait( 1 ) |
14 |
15 | end ) |
16 |
17 | --THING is a screenGui, Moving is the Gui that is supposed to move, and ayy is the gui it's supposed to move to |
This is the other:
01 | script.Parent.MouseButton 1 Click:Connect( function () |
02 |
03 |
04 | local plr = game.Players.LocalPlayer |
05 |
06 | local gls = plr.PlayerGui:WaitForChild( "THING" ) |
07 |
08 | gls.Moving:TweenPosition(UDim 2. new(gls.Oot.Position), "Out" , 4 ) |
09 | end ) |
10 |
11 | --THING is a screenGui, Moving is the Gui that is supposed to move, and Oot is the gui it's supposed to move to |
I mimicked your frame setup, and was able to get it to function properly. For easier use, I put a local script inside "THING" that checks for either button to be pressed, instead of two different scripts for each button. If you wish to have a script within each button instead, by all means.
01 | local plr = game:GetService( "Players" ).LocalPlayer |
02 | local gui = plr.PlayerGui:WaitForChild( "THING" ) |
03 |
04 | gui.ayy.TextButton.MouseButton 1 Click:Connect( function () |
05 |
06 | gui.Moving:TweenPosition(UDim 2. new(gui.ayy.Position.X,gui.ayy.Position.Y),Enum.EasingDirection.Out,Enum.EasingStyle.Quad, 2 , true ) |
07 | -- I believe this was your issue. Using your script just moved the gui's to 0,0,0,0. Position.X and position.Y are the scale and offset for each value, (X is 0,0, Y is the second set of 0,0) |
08 | wait() |
09 | end ) |
10 |
11 |
12 | gui.Oot.TextButton.MouseButton 1 Click:Connect( function () |
13 |
14 | gui.Moving:TweenPosition(UDim 2. new(gui.Oot.Position.X,gui.Oot.Position.Y),Enum.EasingDirection.Out,Enum.EasingStyle.Quad, 2 , true ) |
15 | wait() |
16 | end ) |