local btn = script.Parent.Inventory
local frame = script.Parent.Frame
local btn2 = script.Parent.Inventory2
local z = true
btn.MouseButton1Click:Connect(function()
if z == true then
frame:TweenPosition(UDim2.new(0.13, 0,1.5, 0),"Out",1)
z = false
end
if z == false then
frame:TweenPosition(UDim2.new(0.13, 0,0.115, 0),"Out",1)
z = true
end
end)
im trying to make a tweenservice to make a button go up and down, but it isnt working at all
local btn = script.Parent.Inventory
local frame = script.Parent.Frame
local btn2 = script.Parent.Inventory2
local z = true
btn.MouseButton1Click:Connect(function()
if z == true then -- z == true, passes the check
frame:TweenPosition(UDim2.new(0.13, 0,1.5, 0),"Out",1)
z = false -- Changes "z" to false
end
if z == false then -- z == false, passes the check
frame:TweenPosition(UDim2.new(0.13, 0,0.115, 0),"Out",1)
z = true -- Changes "z" back to true
end
end)
Line 7: z checks if it’s equal to true (Passes)
Line 9: z changes to false
Line 11: z now checks if it’s equal to false (Passes)
Line 13: z changes back to true
z is never switching back to false the way you’d expect it to be
Also make sure that you’re referencing the correct UIObjects within your variables, along with TweenPosition’s Parameters
local btn = script.Parent.Inventory
local frame = script.Parent.Frame
local btn2 = script.Parent.Inventory2
local z = true
btn.MouseButton1Click:Connect(function()
z = not z
if z == true then
frame:TweenPosition(UDim2.new(0.13, 0,1.5, 0), "Out", "Quad", 1, true)
end
if z == false then
frame:TweenPosition(UDim2.new(0.13, 0,0.115, 0), "Out", "Quad", 1, true)
end
end)