This is a script for a basic button press animation script (I guess?)
01 | local down = false |
02 |
03 | local lastpos = script.Parent.Position |
04 |
05 | script.Parent.MouseButton 1 Down:connect( function () |
06 | if down = = false then |
07 | down = true |
08 | script.Parent.Frame.Position = UDim 2. new( 0 , 0 , 0 , 1 ) |
09 | script.Parent.Position:TweenPosition(UDim 2. new(script.Parent.Position + UDim 2. new( 0 , 0 , 0 , 4.5 )), Enum.EasingStyle.Quad) |
10 | script.Parent.Text = "Play" |
11 |
12 | script.Parent.MouseButton 1 Up:connect( function () |
13 | script.Parent.Frame.Position = UDim 2. new( 0 , 0 , 0 , 5 ) |
14 | script.Parent.Position = lastpos |
15 | script.Parent.Text = "Play" |
16 | down = false |
17 | end ) |
18 | end |
19 | end ) |
The output: 21:39:44.953 - TweenPosition is not a valid member of UDim2 21:39:44.953 - Stack Begin 21:39:44.954 - Script 'Players.Player1.PlayerGui.ScreenGui.Frame.TextButton.LocalScript', Line 9 21:39:44.954 - Stack End
Why is TweenPosition not a valid member of UDim2?
1 | script.Parent:TweenPosition(UDim 2. new(script.Parent.Position + UDim 2. new( 0 , 0 , 0 , 4.5 )), Enum.EasingStyle.Quad) |
You don't need to use position as you're tweening off the current position.
01 | local down = false |
02 |
03 | local lastpos = script.Parent |
04 |
05 | script.Parent.MouseButton 1 Down:connect( function () |
06 | if down = = false then |
07 | down = true |
08 | script.Parent.Frame.Position = UDim 2. new( 0 , 0 , 0 , 1 ) |
09 | script.Parent.Position:TweenPosition(UDim 2. new( 0 , 0 , 0 , 4.5 ), 'In' , 'Quad' , . 5 ) |
10 | script.Parent.Text = "Play" |
11 | else |
12 | if down = = true then |
13 | script.Parent.MouseButton 1 Up:connect( function () |
14 | script.Parent:TweenPosition(UDim 2. new( 0 , 0 , 0 , 5 ), 'Out' , 'Quad' , . 5 ) |
15 | script.Parent.Position = lastpos |
16 | script.Parent.Text = "Play" |
17 | down = false |
18 | end ) |
19 | end |
20 | end ) |
This should work I hope you had a lot of mistakes like else. [Edited]