• Two Buttons Not Working
    4 replies, posted
I am making a gamemode, and when I open the team selection menu, it is supposed to have a Team A button and a Team B button but only the Team A one shows up. I know it is something wrong with my code so I just need some help: [CODE]function team_menu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 50,50 ) DermaPanel:SetSize( 200, 250 ) DermaPanel:SetTitle( "ODWars Team Selection" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaButton = vgui.Create( "DButton", TeamA ) DermaButton:SetParent( DermaPanel ) DermaButton:SetPos( 25, 50 ) DermaButton:SetSize( 150, 50 ) DermaButton:SetText( "Team A" ) DermaButton.DoClick = function() RunConsoleCommand( "team_a" ) end local DermaButton = vgui.Create( "DButton", TeamB ) DermaButton:SetParent( DermaPanel ) DermaButton:SetPos( 25, 300 ) DermaButton:SetSize( 150, 50 ) DermaButton:SetText( "Team B" ) DermaButton.DoClick = function() RunConsoleCommand( "team_b" ) end end[/CODE] Do I just name the second one something like DermaButtonB or what? Thanks
Of course two buttons need to have different names, otherwise one will replace the other. By the way, your frame is 200 by 250 but the position of B is at (25,300). Not sure if this button can be inside the frame.
Okay, thanks. It's just that I had the second button as DermaButton1 and I guess you can't use numbers. [B] Edit:[/B] I'm assuming I would also have to change the "DButton" in the quotes to something different as well?
If it was me, I would write: [lua] local DermaButtonA=vgui.Create("DButton",DermaPanel) DermaButtonA:SetText("Team A") ...... local DermaButtonB=vgui.Create("DButton",DermaPanel) DermaButtonB:SetText("Team B") ...... [/lua] "DButton" means that you are making a button, so you should not change it when you want a button.
Okay, thanks.
Sorry, you need to Log In to post a reply to this thread.