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 7 years ago

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

local down = false

local lastpos = script.Parent.Position

script.Parent.MouseButton1Down:connect(function()
    if down == false then
            down = true
            script.Parent.Frame.Position = UDim2.new(0,0,0,1)
            script.Parent.Position:TweenPosition(UDim2.new(script.Parent.Position + UDim2.new(0,0,0,4.5)), Enum.EasingStyle.Quad)
            script.Parent.Text = "Play"

            script.Parent.MouseButton1Up:connect(function()
            script.Parent.Frame.Position = UDim2.new(0,0,0,5)
            script.Parent.Position = lastpos
            script.Parent.Text = "Play"
            down = false
            end)
    end
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?

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
script.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
7 years ago
Edited 7 years ago
local down = false

local lastpos = script.Parent

script.Parent.MouseButton1Down:connect(function()
    if down == false then
            down = true
            script.Parent.Frame.Position = UDim2.new(0,0,0,1)
            script.Parent.Position:TweenPosition(UDim2.new(0,0,0,4.5), 'In', 'Quad', .5)
            script.Parent.Text = "Play"
else
    if down == true then
            script.Parent.MouseButton1Up:connect(function()
            script.Parent:TweenPosition(UDim2.new(0,0,0,5), 'Out', 'Quad', .5)
            script.Parent.Position = lastpos
            script.Parent.Text = "Play"
            down = false
            end)
    end
end)

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

Answer this question