Derma error when i call GetValue() on my slider

Hi, i’m working on a character creation screen, but i’m having some problems getting the value of my slider.
The function i’m using right now is:
[lua]
results.age = age.GetValue()
[/lua](This is on line 225 in the code)

But it comes up with this error:



vgui/DNumSlider.lua:67: attempt to index local 'self' (a nil value)


How do i retrieve the value of my slider?

Another question:
I use this function, when wanna retrieve the info from my DMultiChoice-menu:
[lua]
surname.OnSelect = function(index,value,data)
surnameOption = data
end
[/lua](This is on line 79 in the code)

Later on i just read the “surnameOption” variable.
Isn’t there a function like Getvalue() to use instead?

Source Code
Source code can be found here:
http://pastebay.com/75526
and here:
[lua]
function namepicker(ply, cmd, args)
local width = 500
local height = 500
local padding = 10

local dermaPanel = vgui.Create("DFrame")
dermaPanel:SetPos(ScrW() - width - 50,(ScrH() / 2 - height / 2)) 
dermaPanel:SetSize(width, height)
dermaPanel:SetTitle("Please customize your character") 
dermaPanel:SetVisible(true)
dermaPanel:SetDraggable(false) 
dermaPanel:ShowCloseButton(true)
dermaPanel:MakePopup() 

local propertySheet = vgui.Create("DPropertySheet", dermaPanel)
propertySheet:SetPos(padding, 20 + padding)
propertySheet:SetSize(width - padding * 2, height - 20 - padding * 2)

/* THIS IS THE INTRO SCREEN! */
local introScreen = vgui.Create("DPanelList", dermaPanel)
introScreen:SetPos(padding,20 + padding)
introScreen:SetSize(width - padding * 2, height - 20 - padding * 2)
introScreen:SetSpacing(5) -- Spacing between items
introScreen:EnableHorizontal(false) -- Only vertical items
introScreen:EnableVerticalScrollbar(true) -- Allow scrollbar if you exceed the Y axis

local info = vgui.Create("DLabel", introScreen)
info:SetPos(padding,padding)
info:SetText([[
			Welcome to the server. You need to create your character before joining. 
			Choose with care. You can't change the name and age later on.
			
			To start: go to the next tab in this menu. 
			]])
info:SizeToContents() 

/* THIS IS THE INFO SCREEN*/
local infoScreen = vgui.Create("DPanelList", dermaPanel)
infoScreen:SetPos(padding,20 + padding)
infoScreen:SetSize(width - padding * 2, height - 20 - padding * 2)
infoScreen:SetSpacing(5) -- Spacing between items
infoScreen:EnableHorizontal(false) -- Only vertical items
infoScreen:EnableVerticalScrollbar(true) -- Allow scrollbar if you exceed the Y axis

local firstnameLabel = vgui.Create("DLabel", infoScreen)
firstnameLabel:SetPos(padding,padding)
firstnameLabel:SetText("Please select a firstname: ")
firstnameLabel:SizeToContents() 

local firstname = vgui.Create("DTextEntry", infoScreen)
firstname:SetPos(150,padding)
firstname:SetTall(20)
firstname:SetWide(310)
firstname:SetEnterAllowed(true)

local surnameLabel = vgui.Create("DLabel", infoScreen)
surnameLabel:SetPos(padding,padding + 30)
surnameLabel:SetText("Please select a surname: ")
surnameLabel:SizeToContents() 

local surname = vgui.Create("DMultiChoice", infoScreen)
surname:SetPos(150, padding + 30)
surname:SetSize(310, 20)
surname:SetEditable(false)

surnameOption = ""

local surnames = {
"svendsen", 
"johansen", 
"eriksen",
"iversen", 
"jakobsen"
}
for k,v in pairs(surnames) do
		surname:AddChoice(v) -- Add our options
end 

surname.OnSelect = function(index,value,data)
	surnameOption = data
end

local ageLabel = vgui.Create("DLabel", infoScreen)
ageLabel:SetPos(padding,padding + 75)
ageLabel:SetText("Age of your character: ")
ageLabel:SizeToContents() 

local age = vgui.Create("DNumSlider", infoScreen)
age:SetPos(150,padding + 60)
age:SetSize(310, 250) 
age:SetText("Age of your character")
age:SetMin(15) 
age:SetMax(50) 
age:SetDecimals(0)


/* THE PLAYERMODEL SCREEN */
local modelScreen = vgui.Create("DPanelList", dermaPanel)
modelScreen:SetPos(padding,20 + padding)
modelScreen:SetSize(width - padding * 2, height - 20 - padding * 2)
modelScreen:SetSpacing(5) -- Spacing between items
modelScreen:EnableHorizontal(false) -- Only vertical items
modelScreen:EnableVerticalScrollbar(true) -- Allow scrollbar if you exceed the Y axis

local genderSheet = vgui.Create("DPropertySheet", modelScreen)
genderSheet:SetPos(2, 2)
genderSheet:SetSize(466, 426)

local maleScreen = vgui.Create("DPanelList", modelScreen) 
maleScreen:EnableVerticalScrollbar(true) 
maleScreen:EnableHorizontal(true) 
maleScreen:SetPadding(0) 
maleScreen:SetPos(padding,padding)
maleScreen:SetSize(width - 50, height - 90)

local femaleScreen = vgui.Create("DPanelList", modelScreen) 
femaleScreen:EnableVerticalScrollbar(true) 
femaleScreen:EnableHorizontal(true) 
femaleScreen:SetPadding(0) 
femaleScreen:SetPos(padding,padding)
femaleScreen:SetSize(width - 50, height - 90)
 
local malemodels = {
	"models/player/Group01/male_07.mdl",
	"models/player/Group01/Male_01.mdl",
	"models/player/Hostage/Hostage_01.mdl",
	"models/player/Hostage/Hostage_04.mdl",
	"models/player/Group01/male_07.mdl",
	"models/player/Group01/Male_01.mdl",
	"models/player/Hostage/Hostage_01.mdl",
	"models/player/Hostage/Hostage_04.mdl"
	}
local femalemodels = {
	"models/player/Group01/Female_01.mdl",
	"models/player/Group01/Female_07.mdl",
	"models/player/Group01/Female_01.mdl",
	"models/player/Group01/Female_07.mdl"
	}

playermodel = ""

for k,v in pairs(malemodels) do
	local icon = vgui.Create("SpawnIcon", maleScreen) 
	icon:SetModel(v)
	maleScreen:AddItem(icon)
	icon.DoClick = function(icon) 
		playermodel = v 
		LocalPlayer():EmitSound("click.wav")
	end 
end 	
for k,v in pairs(femalemodels) do
	local icon = vgui.Create("SpawnIcon", maleScreen) 
	icon:SetModel(v)
	femaleScreen:AddItem(icon)
	icon.DoClick = function(icon) 
		playermodel = v 
		LocalPlayer():EmitSound("click.wav")
	end 
end 	

genderSheet:AddSheet("Male", maleScreen, "gui/silkicons/group", false, false, "All the male playermodels goes in here")
genderSheet:AddSheet("Female", femaleScreen, "gui/silkicons/group", false, false, "All the female playermodels goes in here")

/* THE KEYBINDSSCREEN*/
local bindsScreen = vgui.Create("DPanelList", dermaPanel)
bindsScreen:SetPos(padding,20 + padding)
bindsScreen:SetSize(width - padding * 2, height - 20 - padding * 2)
bindsScreen:SetSpacing(5) -- Spacing between items
bindsScreen:EnableHorizontal(false) -- Only vertical items
bindsScreen:EnableVerticalScrollbar(true) -- Allow scrollbar if you exceed the Y axis

local bindsinfo = vgui.Create("DLabel", bindsScreen)
bindsinfo:SetPos(padding,padding)
bindsinfo:SetText([[
				Instead of using the standard keybinds, you can use your own. Just bind these console 
				commands to 2 different keys. If you just wanna use the normal binds, ignore this message. 
				]])
bindsinfo:SizeToContents()


local commandInfo = vgui.Create("DCollapsibleCategory", bindsScreen)
commandInfo:SetPos(padding,60 + padding )
commandInfo:SetSize(450, 50) 
commandInfo:SetExpanded(0) -- Expanded when popped up
commandInfo:SetPadding(5)
commandInfo:SetLabel("Commands, click to view")

local commandinfoWrap = vgui.Create("DPanelList", commandInfo)
commandinfoWrap:SetPos(5,25)
commandinfoWrap:SetSize(440, 100)
commandinfoWrap:SetSpacing(5) -- Spacing between items
commandinfoWrap:EnableHorizontal(true) -- Only vertical items
commandinfoWrap:EnableVerticalScrollbar(true) -- Allow scrollbar if you exceed the Y axis

local commands = vgui.Create("DLabel", commandinfoWrap)
commands:SetPos(padding,padding)
commands:SetText([[
				bind <key> rp_menu
				bind <key> rp_doormenu+
				]])
commands:SizeToContents()

commandInfo:SetContents(commandinfoWrap) -- Add our list above us as the contents of the collapsible category
/* THE GOSCREEN */
local finishScreen = vgui.Create("DPanelList", dermaPanel)
finishScreen:SetPos(padding,20 + padding)
finishScreen:SetSize(width - padding * 2, height - 20 - padding * 2)
finishScreen:SetSpacing(5) -- Spacing between items
finishScreen:EnableHorizontal(false) -- Only vertical items
finishScreen:EnableVerticalScrollbar(true) -- Allow scrollbar if you exceed the Y axis

local finishinfo = vgui.Create("DLabel", finishScreen)
finishinfo:SetPos(padding,padding)
finishinfo:SetText([[Make sure you have entered everything corectly, and then press the button bellow.]])
finishinfo:SizeToContents()

local finishButton = vgui.Create("DButton", finishScreen)
finishButton:SetText("Create my character!")
finishButton:SetPos(padding, 35)
finishButton:SetSize(150, 30)
finishButton.DoClick = function ()
	local results = {}
	results.firstname = firstname:GetValue()
	results.surname = surnameOption
	results.age = age.GetValue()
	results.model = playermodel
	if(results.firstname == "") then
		chat.AddText(Color(255,0,0,255), "Please enter a firstname for your character.")
	elseif(not string.find(results.firstname, "^%a+$")) then
		chat.AddText(Color(255,0,0,255), "The firstname for your character, can only contain letters.")
	elseif(not table.HasValue(surnames, results.surname)) then
		chat.AddText(Color(255,0,0,255), "Please select a surname for your character.")
	elseif(results.age < 15 || results.age < 50) then
		chat.AddText(Color(255,0,0,255), "Your character can't be younger than 15 years or older than 50 years.")
	end
end


/* THIS IS THE TAB-THING */
propertySheet:AddSheet("Intro", introScreen, "gui/silkicons/page", false, false, "Info about the gamemode")
propertySheet:AddSheet("Info", infoScreen, "gui/silkicons/table_edit", false, false, "Choose your name, age etc. ") 
propertySheet:AddSheet("Model", modelScreen, "gui/silkicons/user", false, false, "Choose your playermodel")
propertySheet:AddSheet("Keybinds", bindsScreen, "gui/silkicons/wrench", false, false, "Choose which keys you wanna use to different menues")
propertySheet:AddSheet("GO!", finishScreen, "gui/silkicons/world", false, false, "This is the last step. ")

end
concommand.Add(“rp_name”, namepicker)
[/lua]

[lua]age:GetValue()[/lua]
not
[lua]age.GetValue()[/lua]

[editline]02:37PM[/editline]

About your second question, I think that the way you are doing it at the moment is the only way (not sure though).

Ok thanks :smiley:
I just found a small typo, in my if-statement and change the “.” to “:”. Now it works perfectly. Thanks! :smiley:

In fact, you could set the ConVar that the DMultiChoice changes when a choice is selected, then read the convar.

Look here.

Ok, thanks :slight_smile: