Gui tween not working?

Hey there! So, its as the title says, my gui tween is not working. It just pops up when i press the button and nothing else :pensive:

its supposed to size down the top frame and the main frame and tween up but then it doesn’t so

also if u can tell me how to improve this code then tell me xD

Module Script:

function module:SizeOne(Frame,USize,UPos,Gui,Time,Folder,e,e2) --Frame = frame.
	spawn(function()
		Gui.Enabled = false
	end)
	
	local Clone
	
	if e2 == "go" then
		Clone = Gui:Clone()
		Clone.Enabled = true
		Clone.Parent = Folder
	else
		if Folder:FindFirstChild(Gui.Name) then
			Clone = Folder[Gui.Name]
		else
			Clone = Gui:Clone()
			Clone.Enabled = true
			Clone.Parent = Folder
		end
	end
	
	spawn(function()
		if e == "enable" then
			Clone[Frame.Name].Size = UDim2.new(0.5, 0,0.916, 0)
			Clone[Frame.Name].Position = UDim2.new(0, 692,0, 5)
		end
	end)
	
	task.wait()
	local tween = TweenService:Create(Clone[Frame.Name],TweenInfo.new(Time,Enum.EasingStyle.Cubic,Enum.EasingDirection.In,0,false,0),{Size = USize})--:Play()
	local tween2 = TweenService:Create(Clone[Frame.Name],TweenInfo.new(Time,Enum.EasingStyle.Cubic,Enum.EasingDirection.In,0,false,0),{Position = UPos})--:Play()

	tween:Play()
	tween2:Play()

	tween2.Completed:Connect(function()
		if e == "disable" then
			Clone:Destroy()
		elseif e == "enable" then
			Clone:Destroy()
			Gui.Enabled = true
		end
	end)
end

Now, one question i might get asked is why duplicate the frame? Well, i can’t be bothered to make a long table just to reverse it, it works for the closing when i do the opposite but this doesn’t idk why maybe cuz i use another function (mostly haha)
also, again, if u can tell me how to improve this since duplicating this frame is a bad practice then tell me so!

local script:

Module:SizeOne(adminGui.TopFrame,UDim2.new(0, 692,0, 49),UDim2.new(0.5, 0,0.171, 0),adminGui,.5,PlayerGui:WaitForChild("Clones"),"enable")
Module:SizeOne(adminGui.MainFrame,UDim2.new(0, 692,0, 368),UDim2.new(0.5, 0,0.557, 0),adminGui,.5,PlayerGui:WaitForChild("Clones"),"enable","stop")

anyway, im out of ideas on how to fix this, i’ve come crying to the forums for help again :pensive:

Thanks!!

1 Like

The reason it isn’t working is because you use GuiObject:TweenPosition() to tween position and GuiObject:TweenSize() to tween size.
Here is my fixed version

function module:SizeOne(Frame,USize,UPos,Gui,Time,Folder,e,e2) --Frame = frame.
        Gui.Enabled = false
        local Clone

        if e2 == "go" then
                Clone = Gui:Clone()
                Clone.Enabled = true
                Clone.Parent = Folder
        else
                if Folder:FindFirstChild(Gui.Name) then
                        Clone = Folder[Gui.Name]
                else
                        Clone = Gui:Clone()
                        Clone.Enabled = true
                        Clone.Parent = Folder
                end
        end
        task.wait()
        local tween = Clone[Frame.Name]:TweenSize(USize,Enum.EasingDirection.In,Enum.EasingStyle.Cubic,Time,true)
        local tween2 = Clone[Frame.Name]:TweenPosition(UPos,Enum.EasingDirection.In,Enum.EasingStyle.Cubic,Time)
        task.wait(Time) -- TweenPosition And TweenSize don't yield
        if e == "disable" then
                Clone:Destroy()
        elseif e == "enable" then
                Clone:Destroy()
                Gui.Enabled = true
        end
end
1 Like