I'm trying to tween a Frame. However, when I was testing it only the button changed and the Frame did not move. Is there a problem in the script below? (This is a local script)
01 | local frame = game.StarterGui.FrameGui.Frame |
02 | local button = script.Parent |
03 | local toggle = false |
04 | script.Parent.MouseButton 1 Click:connect( function () |
05 | if toggle = = false then |
06 | toggle = true |
07 | frame:TweenPosition(UDim 2. new( 0.25 ,- 50 , 0.4 ,- 50 ), 'Out' , 'Quad' , 1 ) |
08 | script.Parent.Text = 'Close Shop' |
09 | else |
10 | toggle = false |
11 | frame:TweenPosition(UDim 2. new( 0.25 ,- 50 , 1.4 ,- 50 ), 'In' , 'Quad' , 1 ) |
12 | script.Parent.Text = 'Open Shop' |
13 | end |
14 | end ) |
The problem is your linking to the frame in the StarterGui, you need to link to the frame which is the parent of the button.
01 | local frame = script.Parent.Parent -- I'm guessing the frame is the button's parent...? |
02 | local button = script.Parent |
03 | local toggle = false |
04 | script.Parent.MouseButton 1 Click:connect( function () |
05 | if toggle = = false then |
06 | toggle = true |
07 | frame:TweenPosition(UDim 2. new( 0.25 ,- 50 , 0.4 ,- 50 ), 'Out' , 'Quad' , 1 ) |
08 | script.Parent.Text = 'Close Shop' |
09 | else |
10 | toggle = false |
11 | frame:TweenPosition(UDim 2. new( 0.25 ,- 50 , 1.4 ,- 50 ), 'In' , 'Quad' , 1 ) |
12 | script.Parent.Text = 'Open Shop' |
13 | end |
14 | end ) |