Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"TweenPosition is not a valid member of UDim2"?

Asked by 8 years ago

This is a script for a basic button press animation script (I guess?)

01local down = false
02 
03local lastpos = script.Parent.Position
04 
05script.Parent.MouseButton1Down:connect(function()
06    if down == false then
07            down = true
08            script.Parent.Frame.Position = UDim2.new(0,0,0,1)
09            script.Parent.Position:TweenPosition(UDim2.new(script.Parent.Position + UDim2.new(0,0,0,4.5)), Enum.EasingStyle.Quad)
10            script.Parent.Text = "Play"
11 
12            script.Parent.MouseButton1Up:connect(function()
13            script.Parent.Frame.Position = UDim2.new(0,0,0,5)
14            script.Parent.Position = lastpos
15            script.Parent.Text = "Play"
16            down = false
17            end)
18    end
19end)

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?

2 answers

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago
1script.Parent:TweenPosition(UDim2.new(script.Parent.Position + UDim2.new(0,0,0,4.5)), Enum.EasingStyle.Quad)

You don't need to use position as you're tweening off the current position.

Ad
Log in to vote
0
Answered by
uhTeddy 101
8 years ago
Edited 8 years ago
01local down = false
02 
03local lastpos = script.Parent
04 
05script.Parent.MouseButton1Down:connect(function()
06    if down == false then
07            down = true
08            script.Parent.Frame.Position = UDim2.new(0,0,0,1)
09            script.Parent.Position:TweenPosition(UDim2.new(0,0,0,4.5), 'In', 'Quad', .5)
10            script.Parent.Text = "Play"
11else
12    if down == true then
13            script.Parent.MouseButton1Up:connect(function()
14            script.Parent:TweenPosition(UDim2.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
20end)

This should work I hope you had a lot of mistakes like else. [Edited]

Answer this question