HelpWhy doesnt this button work?

Posts 1–6 of 6 · Page 1 of 1
Why doesnt this button work?
Can someone tell my why this doesnt work?

Code:
function AddToggleButton(n,p,t,b,x,y)
local n = vgui.Create( "Button" )
                n:SetParent( p )
                n:SetText( t )
                n:SetPos( x, y )
                n:SetSize( 85, 25 )
                n.DoClick = function()
				if b then 
				b = false
				else b = true
				end
end
end
AddToggleButton(test, main,"test", q["asdf"]["aimbot"], 200,45)
Thanks <3
Try this
Code:
function AddToggleButton(n,p,t,b,x,y)
n = vgui.Create( "Button" )
                n:SetParent( p )
                n:SetText( t )
                n:SetPos( x, y )
                n:SetSize( 85, 25 )
                n.DoClick = function()
				if b then 
				b = false
				else b = true
				end
return n
end
end
local test = AddToggleButton(test, main,"test", q["asdf"]["aimbot"], 200,45)
Quote Originally Posted by suchisgood View Post
Try this
Code:
function AddToggleButton(n,p,t,x,y)
n = vgui.Create( "Button" )
                n:SetParent( p )
                n:SetText( t )
                n:SetPos( x, y )
                n:SetSize( 85, 25 )
                n.DoClick = function()
				if b then 
				b = false
				else b = true
				end
return n
end
end
local test = AddToggleButton(test, main,"test", q["asdf"]["aimbot"], 200,45)
I tried it.

Code:
function AddToggleButton(n,p,t,b,x,y)
n = vgui.Create( "Button" )
                n:SetParent( p )
                n:SetText( t )
                n:SetPos( x, y )
                n:SetSize( 85, 25 )
                n.DoClick = function()
				if q["asdf"]["aimbot"] then 
				q["asdf"]["aimbot"] = false
				else q["asdf"]["aimbot"] = true
				end
return n
end
end
local test = AddToggleButton(test, main,"test", 200,45)
This works, however i need to be able to add buttons with different booleans ofc.
Quote Originally Posted by color0a View Post
I tried it.

Code:
function AddToggleButton(n,p,t,b,x,y)
n = vgui.Create( "Button" )
                n:SetParent( p )
                n:SetText( t )
                n:SetPos( x, y )
                n:SetSize( 85, 25 )
                n.DoClick = function()
				if q["asdf"]["aimbot"] then 
				q["asdf"]["aimbot"] = false
				else q["asdf"]["aimbot"] = true
				end
return n
end
end
local test = AddToggleButton(test, main,"test", 200,45)
This works, however i need to be able to add buttons with different booleans ofc.
Do the same and change test to test2!
What do you mean? I would prefer to only have to write the Addtogglebutton function once, then use it to easily add more buttons with AddToggleButton() Could you elaborate please.

so theres no way to add
Code:
q["asdf"]["aimbot"]
inside the brackets in AddToggleButton that would work?
//Solved <3 2short
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us