Hi guys need your help(I'm just a beginner programmer )DFrame/RunConsoleCommand
5 replies, posted
Hi .
I do not understand what's wrong! See the function .
function myButton: DoClick ()
myParent: SetVisible (false);
end
And this function, that when you click on the button, the player assigned a command through the console to the profession (This way, profession is selected via say) myButton.DoClick = function (self) RunConsoleCommand ("say", "/ baba") end
(I want to make it so that when you click a button it changes to a certain profession and closes the DFrame)
All code
function Fractiont()
local myParent = vgui.Create("Frame");
myParent:SetSize( 1600, 900 )
myParent:SetVisible(true);
myParent:Center()
local myButton = vgui.Create("Button", myParent);
myButton:SetPos( 180, 203 )
myButton:SetSize( 300, 45 )
myButton:SetText("СССР");
myButton.DoClick = function (self) RunConsoleCommand("say", "/baba") end
function myButton:DoClick()
myParent:SetVisible(false);
end
end
Well you’re overriding myButton.DoClick twice. What you need to understand is that
function myButton:DoClick() end
Is the same as
myButton.DoClick = function() end
You are first making DoClick call RunConsoleCommand, then you’re overriding it by making it so myParent:SetVisible(false). I’m assuming you want to do both which can be done by the following function.
function myButton:DoClick()
RunConsoleCommand(“say”, “/bla”)
myParent:SetVisible(false)
end
Such a small informality was, thank you! How here to give you a positive feedback?
Simply marking my answer as a solution is enough, and no problem!
That’s new and kind of stupid
Sorry, you need to Log In to post a reply to this thread.