Entire script just doesnt work at all

so basically, im making a little number line that tweens out and displays numbers for you to click on. a button activates this number line. 4 states:
visible
not visible
in (meaning the number line is ready to tween out and the numbers are ready to be displayed, just hasnt happened yet)
out (meaning the numberline has tweened out)
the states start out on not visible and in
when you click the button, it should become visible and then tween out, but that doesnt happen here
No errors produced, nothing happens.

local Out = {
	["arrowleft"] = UDim2.new(0.04,0,0.5,0),
	["arrowright"] = UDim2.new(0.953,0,0.5,0),
	["linepos"] = UDim2.new(0.5,0,0.5,0),
	["linesize"] = UDim2.new(0,425,0,3),
	["one"] = true,
	["two"] = true,
	["zero"] = true,
	["onefive"] = true,
	["zerofive"] = true,
	["containerpos"] = UDim2.new(0.5,0,0.85,0),
	["containersize"] = UDim2.new(0,450,0,40)
}
local In = {
	["arrowleft"] = UDim2.new(0.25,0,0.5,0),
	["arrowright"] = UDim2.new(0.743,0,0.5,0),
	["linepos"] = UDim2.new(0.5,0,0.5,0),
	["linesize"] = UDim2.new(0,30,0,3),
	["one"] = false,
	["two"] = false,
	["zero"] = false,
	["onefive"] = false,
	["zerofive"] = false,
	["containerpos"] = UDim2.new(0.5,0,0.85,0),
	["containersize"] = UDim2.new(0,50,0,40)
}
local state = "In"
local isVisible = false
local bar = script.Parent.scalecontainer
local button = script.Parent.container.timescale
local line = bar.line
local one = line.one
local two = line.two
local zero = line.zero
local zerofive = line.zerofive
local onefive = line.onefive
local arrowleft = bar.arrowleft
local arrowright = bar.arrowright
local Time = script.Parent.Time
local ts = game:GetService("TweenService")
local tiout = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local tiin = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local rs = game:GetService("RunService")
local db = false
local visibilityState = false

function TweenOut()
	ts:Create(arrowleft,tiout,{Position = Out["arrowleft"]}):Play()
	ts:Create(arrowright,tiout,{Position = Out["arrowright"]}):Play()
	ts:Create(line,tiout,{Position = Out["linepos"], Size = Out["linesize"]}):Play()
	ts:Create(bar,tiout,{Position = Out["containerpos"], Size = Out["containersize"]}):Play()
	task.wait(0.75)
	one.Visible = Out["one"]
	two.Visible = Out["two"]
	zero.Visible = Out["zero"]
	zerofive.Visible = Out["zerofive"]
	onefive.Visible = Out["onefive"]
	script.UIARCBarOpen.Parent = bar
	script.UIARClineopen.Parent = line
	script.UIARCarrowleftopen.Parent = arrowleft
	script.UIARCarrowrightopen.Parent = arrowright
	bar.UIARCbarclosed.Parent = script
	line.UIARClineclosed.Parent = script
	arrowleft.UIARCarrowleftclosed.Parent = script
	arrowright.UIARCarrowrightclosed.Parent = script
end

function TweenIn()
	ts:Create(arrowleft,tiin,{Position = In["arrowleft"]}):Play()
	ts:Create(arrowright,tiin,{Position = In["arrowright"]}):Play()
	ts:Create(line,tiin,{Position = In["linepos"], Size = In["linesize"]}):Play()
	ts:Create(bar,tiin,{Position = In["containerpos"], Size = In["containersize"]}):Play()
	task.wait(0.75)
	one.Visible = In["one"]
	two.Visible = In["two"]
	zero.Visible = In["zero"]
	zerofive.Visible = In["zerofive"]
	onefive.Visible = In["onefive"]
	script.UIARCbarclosed.Parent = bar
	script.UIARClineclosed.Parent = line
	script.UIARCarrowleftclosed.Parent = arrowleft
	script.UIARCarrowrightclosed.Parent = arrowright
	bar.UIARCBarOpen.Parent = script
	line.UIARClineopen.Parent = script
	arrowleft.UIARCarrowleftopen.Parent = script
	arrowright.UIARCarrowrightopen.Parent = script
end

function visibilityToggle(visibility)
	if visibility == false then
		if state == "In" then
			bar.Visible = false
			arrowright.Visible = false
			arrowleft.Visible = false
			line.Visible = false
		elseif state == "Out" then
			TweenIn()
			bar.Visible = false
			arrowright.Visible = false
			arrowleft.Visible = false
			line.Visible = false
		end
	else
		if state == "In" then
			bar.Visible = true
			arrowright.Visible = true
			arrowleft.Visible = true
			line.Visible = true
			wait(0.75)
			TweenOut()
		elseif state == "Out" then
			TweenIn()
			bar.Visible = true
			arrowright.Visible = true
			arrowleft.Visible = true
			line.Visible = true
			task.wait(0.75)
			TweenOut()
		end
	end
end

function ResetTime()
	Time.Value = 5
end
while task.wait(1) do
	Time.Value -= 1
end
rs.RenderStepped:Connect(function()
      if Time.Value <= 0 then
			TweenIn()
			visibilityToggle(false)
			ResetTime()
		end
end)

button.Activated:Connect(function()
	ResetTime()
	if db == false then
		db = true
		if visibilityState == false then
			visibilityToggle(true)
			visibilityState = true
		else
			visibilityToggle(false)
			visibilityState = false
		end
		task.wait(2)
		db = false
	end
end)

good luck deciphering my terrible code

Swap these lines around and I like your code struture. Top down hot rod.

button.Activated:Connect(function()
    local visibilityState = false

putting the variable inside the button event didnt do anything, same thing still occurs (no errors, not doing anything)

PS: thank you for the compliment

visibilityState is being re-initialized to false every time the button is clicked.
Move visibilityState outside the connect fuction.

i seemed to have put minimally dated code as my playtest had the variable outside of the code. Let me repaste the current code i have right now (either way, the place i put it doesn’t fix it)

local Out = {
	["arrowleft"] = UDim2.new(0.04,0,0.5,0),
	["arrowright"] = UDim2.new(0.953,0,0.5,0),
	["linepos"] = UDim2.new(0.5,0,0.5,0),
	["linesize"] = UDim2.new(0,425,0,3),
	["one"] = true,
	["two"] = true,
	["zero"] = true,
	["onefive"] = true,
	["zerofive"] = true,
	["containerpos"] = UDim2.new(0.5,0,0.85,0),
	["containersize"] = UDim2.new(0,450,0,40)
}
local In = {
	["arrowleft"] = UDim2.new(0.25,0,0.5,0),
	["arrowright"] = UDim2.new(0.743,0,0.5,0),
	["linepos"] = UDim2.new(0.5,0,0.5,0),
	["linesize"] = UDim2.new(0,30,0,3),
	["one"] = false,
	["two"] = false,
	["zero"] = false,
	["onefive"] = false,
	["zerofive"] = false,
	["containerpos"] = UDim2.new(0.5,0,0.85,0),
	["containersize"] = UDim2.new(0,50,0,40)
}
local state = "In"
local isVisible = false
local bar = script.Parent.scalecontainer
local button = script.Parent.container.timescale
local line = bar.line
local one = line.one
local two = line.two
local zero = line.zero
local zerofive = line.zerofive
local onefive = line.onefive
local arrowleft = bar.arrowleft
local arrowright = bar.arrowright
local Time = script.Parent.Time
local ts = game:GetService("TweenService")
local tiout = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local tiin = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local rs = game:GetService("RunService")
local db = false
local visibilityState = false

function TweenOut()
	ts:Create(arrowleft,tiout,{Position = Out["arrowleft"]}):Play()
	ts:Create(arrowright,tiout,{Position = Out["arrowright"]}):Play()
	ts:Create(line,tiout,{Position = Out["linepos"], Size = Out["linesize"]}):Play()
	ts:Create(bar,tiout,{Position = Out["containerpos"], Size = Out["containersize"]}):Play()
	task.wait(0.75)
	one.Visible = Out["one"]
	two.Visible = Out["two"]
	zero.Visible = Out["zero"]
	zerofive.Visible = Out["zerofive"]
	onefive.Visible = Out["onefive"]
	script.UIARCBarOpen.Parent = bar
	script.UIARClineopen.Parent = line
	script.UIARCarrowleftopen.Parent = arrowleft
	script.UIARCarrowrightopen.Parent = arrowright
	bar.UIARCbarclosed.Parent = script
	line.UIARClineclosed.Parent = script
	arrowleft.UIARCarrowleftclosed.Parent = script
	arrowright.UIARCarrowrightclosed.Parent = script
end

function TweenIn()
	ts:Create(arrowleft,tiin,{Position = In["arrowleft"]}):Play()
	ts:Create(arrowright,tiin,{Position = In["arrowright"]}):Play()
	ts:Create(line,tiin,{Position = In["linepos"], Size = In["linesize"]}):Play()
	ts:Create(bar,tiin,{Position = In["containerpos"], Size = In["containersize"]}):Play()
	task.wait(0.75)
	one.Visible = In["one"]
	two.Visible = In["two"]
	zero.Visible = In["zero"]
	zerofive.Visible = In["zerofive"]
	onefive.Visible = In["onefive"]
	script.UIARCbarclosed.Parent = bar
	script.UIARClineclosed.Parent = line
	script.UIARCarrowleftclosed.Parent = arrowleft
	script.UIARCarrowrightclosed.Parent = arrowright
	bar.UIARCBarOpen.Parent = script
	line.UIARClineopen.Parent = script
	arrowleft.UIARCarrowleftopen.Parent = script
	arrowright.UIARCarrowrightopen.Parent = script
end

function visibilityToggle(visibility)
	if visibility == false then
		if state == "In" then
			bar.Visible = false
			arrowright.Visible = false
			arrowleft.Visible = false
			line.Visible = false
		elseif state == "Out" then
			TweenIn()
			bar.Visible = false
			arrowright.Visible = false
			arrowleft.Visible = false
			line.Visible = false
		end
	else
		if state == "In" then
			bar.Visible = true
			arrowright.Visible = true
			arrowleft.Visible = true
			line.Visible = true
			wait(0.75)
			TweenOut()
		elseif state == "Out" then
			TweenIn()
			bar.Visible = true
			arrowright.Visible = true
			arrowleft.Visible = true
			line.Visible = true
			task.wait(0.75)
			TweenOut()
		end
	end
end

function ResetTime()
	Time.Value = 5
end
while task.wait(1) do
	Time.Value -= 1
end
rs.RenderStepped:Connect(function()
      if Time.Value <= 0 then
			TweenIn()
			visibilityToggle(false)
			ResetTime()
		end
end)

button.Activated:Connect(function()
	ResetTime()
	if db == false then
		db = true
		if visibilityState == false then
			visibilityToggle(true)
			visibilityState = true
		else
			visibilityToggle(false)
			visibilityState = false
		end
		task.wait(2)
		db = false
	end
end)

Nope. Same thing.
One thing to note is that my “time” variable doesnt seem to work (the function of it is to stop showing the line after 5 seconds have passed)
image
it continues to go on past 0 which is not what i want

Well you can’t move forward with errors on the table. Is this that massive Gui I saw the other day?
I’m overwriting my script post … (keep in mind I’m guessing, don’t have your setup)

i dont know how to respond to this…Yeah, I know but like I don’t know why its not working

local Out = {
    ["arrowleft"] = UDim2.new(0.04, 0, 0.5, 0),
    ["arrowright"] = UDim2.new(0.953, 0, 0.5, 0),
    ["linepos"] = UDim2.new(0.5, 0, 0.5, 0),
    ["linesize"] = UDim2.new(0, 425, 0, 3),
    ["one"] = true,
    ["two"] = true,
    ["zero"] = true,
    ["onefive"] = true,
    ["zerofive"] = true,
    ["containerpos"] = UDim2.new(0.5, 0, 0.85, 0),
    ["containersize"] = UDim2.new(0, 450, 0, 40)
}

local In = {
    ["arrowleft"] = UDim2.new(0.25, 0, 0.5, 0),
    ["arrowright"] = UDim2.new(0.743, 0, 0.5, 0),
    ["linepos"] = UDim2.new(0.5, 0, 0.5, 0),
    ["linesize"] = UDim2.new(0, 30, 0, 3),
    ["one"] = false,
    ["two"] = false,
    ["zero"] = false,
    ["onefive"] = false,
    ["zerofive"] = false,
    ["containerpos"] = UDim2.new(0.5, 0, 0.85, 0),
    ["containersize"] = UDim2.new(0, 50, 0, 40)
}

local bar = script.Parent.scalecontainer
local button = script.Parent.container.timescale
local line = bar.line
local one = line.one
local two = line.two
local zero = line.zero
local zerofive = line.zerofive
local onefive = line.onefive
local arrowleft = bar.arrowleft
local arrowright = bar.arrowright
local Time = script.Parent.Time
local ts = game:GetService("TweenService")
local tiout = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tiin = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
local rs = game:GetService("RunService")
local db = false
local visibilityState = false

function TweenOut()
    ts:Create(arrowleft, tiout, {Position = Out["arrowleft"]}):Play()
    ts:Create(arrowright, tiout, {Position = Out["arrowright"]}):Play()
    ts:Create(line, tiout, {Position = Out["linepos"], Size = Out["linesize"]}):Play()
    ts:Create(bar, tiout, {Position = Out["containerpos"], Size = Out["containersize"]}):Play()
    task.wait(0.75)
    one.Visible = Out["one"]
    two.Visible = Out["two"]
    zero.Visible = Out["zero"]
    zerofive.Visible = Out["zerofive"]
    onefive.Visible = Out["onefive"]
end

function TweenIn()
    ts:Create(arrowleft, tiin, {Position = In["arrowleft"]}):Play()
    ts:Create(arrowright, tiin, {Position = In["arrowright"]}):Play()
    ts:Create(line, tiin, {Position = In["linepos"], Size = In["linesize"]}):Play()
    ts:Create(bar, tiin, {Position = In["containerpos"], Size = In["containersize"]}):Play()
    task.wait(0.75)
    one.Visible = In["one"]
    two.Visible = In["two"]
    zero.Visible = In["zero"]
    zerofive.Visible = In["zerofive"]
    onefive.Visible = In["onefive"]
end

function visibilityToggle(visibility)
    if visibility then
        if not visibilityState then
            visibilityState = true
            bar.Visible = true
            arrowright.Visible = true
            arrowleft.Visible = true
            line.Visible = true
            TweenIn()
        end
    else
        if visibilityState then
            visibilityState = false
            TweenOut()
            bar.Visible = false
            arrowright.Visible = false
            arrowleft.Visible = false
            line.Visible = false
        end
    end
end

function ResetTime()
    Time.Value = 5
end

local function countdown()
    while Time.Value > 0 do task.wait(1)
        Time.Value = Time.Value - 1
    end visibilityToggle(false)
    ResetTime()
end

countdown()
rs.RenderStepped:Connect(function()
    if Time.Value == 0 then
        visibilityToggle(false)
        ResetTime()
    end
end)

button.Activated:Connect(function()
    if not db then db = true
        visibilityToggle(not visibilityState)
        ResetTime() task.wait(2)
        db = false
    end
end)

nvm i see now (crfowehtguiowr) (characters)

my code is still the same so now im confused again

My bad, I did copy that short. Reposted. I kind of don’t like spaces.

sorry for the late reply, but your updated code doesn’t count down now ;-; its just stuck at 5

Sorry. I really need something to work with or I’m terrible at blind guessing.

like how i setup my UI itself? you want explorer?
(ps: fixed i just had to delete renderstepped)

That’s great news. Good debugging! I was kinda sus of that one too.

i added something else for the tweening and i got this error (UIARCbarclosed is just one of my UI elements. its original parent is in the bar
image
(scalecontainer being the bar)
UIARCbarclosed is not a valid member of LocalScript “Players.DevYeetaludedus.PlayerGui.main.TweenHandler”
updated code

local Out = {
	["arrowleft"] = UDim2.new(0.04,0,0.5,0),
	["arrowright"] = UDim2.new(0.953,0,0.5,0),
	["linepos"] = UDim2.new(0.5,0,0.5,0),
	["linesize"] = UDim2.new(0,425,0,3),
	["one"] = true,
	["two"] = true,
	["zero"] = true,
	["onefive"] = true,
	["zerofive"] = true,
	["containerpos"] = UDim2.new(0.5,0,0.85,0),
	["containersize"] = UDim2.new(0,450,0,40)
}
local In = {
	["arrowleft"] = UDim2.new(0.25,0,0.5,0),
	["arrowright"] = UDim2.new(0.743,0,0.5,0),
	["linepos"] = UDim2.new(0.5,0,0.5,0),
	["linesize"] = UDim2.new(0,30,0,3),
	["one"] = false,
	["two"] = false,
	["zero"] = false,
	["onefive"] = false,
	["zerofive"] = false,
	["containerpos"] = UDim2.new(0.5,0,0.85,0),
	["containersize"] = UDim2.new(0,50,0,40)
}
local state = "In"
local isVisible = false
local bar = script.Parent.scalecontainer
local button = script.Parent.container.timescale
local line = bar.line
local one = line.one
local two = line.two
local zero = line.zero
local zerofive = line.zerofive
local onefive = line.onefive
local arrowleft = bar.arrowleft
local arrowright = bar.arrowright
local Time = script.Parent.Time
local ts = game:GetService("TweenService")
local tiout = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local tiin = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local rs = game:GetService("RunService")
local db = false
local visibilityState = false

function TweenOut(	)
	ts:Create(arrowleft,tiout,{Position = Out["arrowleft"]}):Play()
	ts:Create(arrowright,tiout,{Position = Out["arrowright"]}):Play()
	ts:Create(line,tiout,{Position = Out["linepos"], Size = Out["linesize"]}):Play()
	ts:Create(bar,tiout,{Position = Out["containerpos"], Size = Out["containersize"]}):Play()
	task.wait(0.75)
	one.Visible = Out["one"]
	two.Visible = Out["two"]
	zero.Visible = Out["zero"]
	zerofive.Visible = Out["zerofive"]
	onefive.Visible = Out["onefive"]
	script.UIARCBarOpen.Parent = bar
	script.UIARClineopen.Parent = line
	script.UIARCarrowleftopen.Parent = arrowleft
	script.UIARCarrowrightopen.Parent = arrowright
	bar.UIARCbarclosed.Parent = script
	line.UIARClineclosed.Parent = script
	arrowleft.UIARCarrowleftclosed.Parent = script
	arrowright.UIARCarrowrightclosed.Parent = script
end

function TweenIn()
	ts:Create(arrowleft,tiin,{Position = In["arrowleft"]}):Play()
	ts:Create(arrowright,tiin,{Position = In["arrowright"]}):Play()
	ts:Create(line,tiin,{Position = In["linepos"], Size = In["linesize"]}):Play()
	ts:Create(bar,tiin,{Position = In["containerpos"], Size = In["containersize"]}):Play()
	task.wait(0.75)
	one.Visible = In["one"]
	two.Visible = In["two"]
	zero.Visible = In["zero"]
	zerofive.Visible = In["zerofive"]
	onefive.Visible = In["onefive"]
	script.UIARCbarclosed.Parent = bar
	script.UIARClineclosed.Parent = line
	script.UIARCarrowleftclosed.Parent = arrowleft
	script.UIARCarrowrightclosed.Parent = arrowright
	bar.UIARCBarOpen.Parent = script
	line.UIARClineopen.Parent = script
	arrowleft.UIARCarrowleftopen.Parent = script
	arrowright.UIARCarrowrightopen.Parent = script
end

function visibilityToggle(visibility)
	if visibility then
		if not visibilityState then
			visibilityState = true
			bar.Visible = true
			arrowright.Visible = true
			arrowleft.Visible = true
			line.Visible = true
			TweenIn()
		end
	else
		if visibilityState then
			visibilityState = false
			TweenOut()
			bar.Visible = false
			arrowright.Visible = false
			arrowleft.Visible = false
			line.Visible = false
		end
	end
end

function ResetTime()
	Time.Value = 5
end

function countdown()
	while Time.Value > 0 do task.wait(1)
		Time.Value = Time.Value - 1
	end
	visibilityToggle(false)
	ResetTime()
end

countdown()

button.Activated:Connect(function()
	if not db then db = true
		visibilityToggle(not visibilityState)
		ResetTime() task.wait(2)
		if visibilityState and state == "In" then TweenOut() elseif visibilityState and state == "Out" then TweenIn() end
		db = false
	end
end)

further context: i store part of my UIelements in the script because they are not used until the bar is out
different values of the same element is used for when the bar is in so i just swap them each time

i read back at what i said and i see a simple solution (grrrr)

Looks right, typo maybe?

print(bar:FindFirstChild("UIARCbarclosed"))

Did it find it? And this is hard to read… UIarcBarClosed, UIarcArrowRightOpen stands out.

I used a different solution i found. Simply change the values of the UI elements to the correct ones for in and out.

Now another issue has come up (here we go again)
the counter isnt counting anymore
it does it once but never again