Broken GUI| How do i fix this

Hello!(Sorry for bad english :neutral_face: ). I’m very new to scripting. I don’t know what the problem is. Can someone take a look at my script and tell me what’s wrong. It opens fine for the first few times after that it starts glitching. Ty!
https://streamable.com/n8q3bd

local UserInputService = game:GetService("UserInputService")
local  frame = script.Parent:WaitForChild("Frame")
local db = true 
UserInputService.InputBegan:Connect (function(input,gameProcessedEvent)

if input.UserInputType == Enum.UserInputType.Keyboard then
	if input.KeyCode == Enum.KeyCode.Tab then
			if db == true   then
				
		
	script.Parent.Frame.Visible = true
	frame:TweenSizeAndPosition(
       UDim2.new(0,472,0,404),
       UDim2.new(0.214,0,0.155,0),
			
				"Out",
				"Elastic"
				
				)

			for i,v in pairs(script.Parent.Frame:GetChildren())  do 
				if v:IsA("TextButton") then
					v.Visible = true
					v:TweenSize(

						UDim2.new(0, 141,0,88),
						"Out",		
						"Elastic",
                        5

					)
 

				end
			end

			db  =false

			else 
				
				script.Parent.Frame.Visible = false
				frame:TweenSizeAndPosition(
					UDim2.new(0,0,0,0),
					UDim2.new(0.5,0,0.5,0),

					"Out",
					"Elastic"

				)

				for i,v in pairs(script.Parent.Frame:GetChildren())  do 
					if v:IsA("TextButton") then
						v.Visible = false
						v:TweenSize(

							UDim2.new(0, 0,0,0),
							"Out",		
							"Elastic",
							5

						)
					end
				end
		db =true
		end
	end
end
end)

Can you please format the code properly, its really hard to debug in this way.

Oh my bad, Is it readable now ?

The spacing makes it very hard to read, here is a version without the spacing which is what I assume they were talking about. I would help with this bug if it wasn’t 2 AM and I wasn’t about to go to bed. I can help tomorrow if it’s still not fixed.

local UserInputService = game:GetService("UserInputService")
local frame = script.Parent:WaitForChild("Frame")
local db = true

UserInputService.InputBegan:Connect(function(input,gameProcessedEvent)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.Tab then
			if db == true then
				script.Parent.Frame.Visible = true
				frame:TweenSizeAndPosition(UDim2.new(0,472,0,404), UDim2.new(0.214,0,0.155,0), "Out", "Elastic")
				for i,v in pairs(script.Parent.Frame:GetChildren())  do
					if v:IsA("TextButton") then
						v.Visible = true
						v:TweenSize(UDim2.new(0, 141,0,88), "Out", "Elastic", 5)
					end
				end
				db = false
			else
				script.Parent.Frame.Visible = false
				frame:TweenSizeAndPosition(UDim2.new(0,0,0,0), UDim2.new(0.5,0,0.5,0), "Out", "Elastic")
				for i,v in pairs(script.Parent.Frame:GetChildren())  do
					if v:IsA("TextButton") then
						v.Visible = false
						v:TweenSize(UDim2.new(0, 0,0,0), "Out", "Elastic", 5)
					end
				end
				db = true
			end
		end
	end
end)
1 Like

Ty for your time… the bug was gui overlaping each other… it’s fixed now thank you =]