I have a GUI that I want to tween when a button is clicked, and I'm pretty sure I wrote it correctly because I compared it to another working tween script I have.
button.MouseButton1Up:Connect(function() if not selected then InventoryFrame:TweenPosition( UDim2.new(0.499, 0, 0.063, 0) "Out", "Quad", 1, true ) selected = true else InventoryFrame:TweenPosition( UDim2.new(1.2, 0, 0.063, 0), "Out", "Quad", 1, true ) selected = false end end)
When I click the button I get an output saying Players.frogeater12345.PlayerGui.Hotbar.Hotbar.Inventory5.InventoryButtonScript:9: attempt to call a UDim2 value
Try this, instead of doing "if not selected then", try to remove those parts and don't do the else statement because it is like saying if I pressed it then the GUI stays the same or something like that, just make sure the GUI is off of the screen before you press the button the open the GUI.
For example, this is what I did for one of my GUI's:
local QuoteButton = script.Parent.MainMenu.QuoteoftheMonthButton local quote = script.Parent.QuoteoftheMonth local Exit = script.Parent.QuoteoftheMonth.ExitButton QuoteButton.MouseButton1Click:Connect(function() local mouse = game.Players.LocalPlayer:GetMouse() script.Parent.Parent.Click:Play(mouse) quote:TweenPosition( UDim2.new(0.296, 0,0.103, 0), "Out", "Quart", 1, false, nil ) end) Exit.MouseButton1Click:Connect(function() local mouse = game.Players.LocalPlayer:GetMouse() script.Parent.Parent.Click:Play(mouse) quote:TweenPosition( UDim2.new(0.296, 0,-1, 0), "Out", "Quart", 1, false, nil ) end)