DNumSlider problem

Hey guys, I’m attempting to change the max range of a radar I’m working on and everytime I have the derma change the value it stays the same, apparently; here’s the code.
[lua]
–Panel that’s handling the stuff.
usermessage.Hook(“dist_menu”,function()
local main = vgui.Create(“DFrame”)
main:Center()
main:MakePopup()
main:SetTitle(" “)
main:SetSize(200,100)
main:ShowCloseButton(true)
main.Paint = function()
draw.RoundedBox(6,0,0,main:GetWide(),20,color_black)
draw.RoundedBox(6,0,30,main:GetWide(),main:GetTall()/2,color_black)
draw.SimpleText(“HAS System Options”,“Trebuchet19”,35,0,color_white)
end
local dist = vgui.Create(“DNumSlider”,main)
dist:SetPos(20,30)
dist:SetWide(150)
dist:SetText(“Radar Distance”)
dist:SetMin(50)
dist:SetMax(600)
dist:SetValue(cam_dist)
dist.OnValueChanged = function(panel,value)
cam_dist = value
end
local but = vgui.Create(“DButton”,main)
but:SetText(”>")
but:SetSize(15,10)
but:SetPos(180,70)
but.DoClick = function()
cam_dist = dist:GetValue()
main:Close()
end
end)
–Renderscript
local cam_dist = cam_dist or 0
local function Radar()
draw.RoundedBox(6,0,0,250,150,Color(0,0,0,155))
local CamData = {}
CamData.angles = Angle(50,LocalPlayer():EyeAngles().yaw,0)
CamData.origin = LocalPlayer():GetPos()+Vector(0,0,cam_dist)
CamData.x = 20
CamData.y = 20
CamData.w = 200
CamData.h = 100
CamData.drawviewmodel = false
render.RenderView( CamData )
if LP():Health() < 10 then
for i = 1,9 do
draw.RoundedBoxEx(1,math.random(-10,0),0,250,150,Color(55,55,math.random(55,155),math.sin(CurTime()*math.abs(2))*255))
end
end
draw.RoundedBox(6,0,0,250,30,color_black)
draw.RoundedBox(6,0,0,30,150,color_black)
draw.RoundedBox(6,0,120,250,30,color_black)
draw.RoundedBox(6,220,0,30,150,color_black)
if checkIf then
draw.RoundedBox(6,30+math.sin(CurTime()*math.abs(3))*20,200,225,20,Color(0,0,0,655-textPos:Distance(LP():GetPos())))
draw.SimpleText("Current Location: "…shopName,“Trebuchet19”,30+math.sin(CurTime()*math.abs(3))*20,200,Color(r,g,b,655-textPos:Distance(LP():GetPos())))
end
draw.RoundedBox(6,CamData.w/2+20,CamData.h/2+20,10,10,Color(255,0,0,55))
draw.SimpleText("Freedom HAS System: ",“Trebuchet19”,0.5,0,color_white); if LP():Health() > 10 then draw.SimpleText("ON_STATUS ",“Trebuchet19”,150,0,Color(0,255,0,math.sin(CurTime()*math.abs(2))*155)) else draw.SimpleText("DAMAGE_ST ",“Trebuchet19”,150,0,Color(255,0,0,math.sin(CurTime()*math.abs(2))*155)) end
draw.SimpleText(“HP:”,“Trebuchet”,0,117,Color(0,255,0,255))
draw.RoundedBox(2,30,122,LP():Health()*2.10,10,Color(0,255,0,255))
draw.SimpleText(“AR:”,“Trebuchet”,0,132,Color(0,0,255,255))
draw.RoundedBox(2,30,136,LP():Armor()*2.10,10,Color(0,0,255,255))
end
hook.Add(“HUDPaint”, “Radar_Create”,Radar)
[/lua]
Any help is appreciated :>

Try this:

[lua]
–Renderscript
local cam_dist = cam_dist or 0

local function Radar()
draw.RoundedBox(6,0,0,250,150,Color(0,0,0,155))
local CamData = {}
CamData.angles = Angle(50,LocalPlayer():EyeAngles().yaw,0)
CamData.origin = LocalPlayer():GetPos()+Vector(0,0,cam_dist)
CamData.x = 20
CamData.y = 20
CamData.w = 200
CamData.h = 100
CamData.drawviewmodel = false
render.RenderView( CamData )
if LocalPlayer():Health() < 10 then
for i = 1,9 do
draw.RoundedBoxEx(1,math.random(-10,0),0,250,150,Color(55,55,math.random(55,155),math.sin(CurTime()*math.abs(2))*255))
end
end
draw.RoundedBox(6,0,0,250,30,color_black)
draw.RoundedBox(6,0,0,30,150,color_black)
draw.RoundedBox(6,0,120,250,30,color_black)
draw.RoundedBox(6,220,0,30,150,color_black)
if checkIf then
draw.RoundedBox(6,30+math.sin(CurTime()*math.abs(3))*20,200,225,20,Color(0,0,0,655-textPos:Distance(LocalPlayer():GetPos())))
draw.SimpleText("Current Location: "…shopName,“Trebuchet19”,30+math.sin(CurTime()*math.abs(3))*20,200,Color(r,g,b,655-textPos:Distance(LocalPlayer():GetPos())))
end
draw.RoundedBox(6,CamData.w/2+20,CamData.h/2+20,10,10,Color(255,0,0,55))
draw.SimpleText("Freedom HAS System: ",“Trebuchet19”,0.5,0,color_white); if LocalPlayer():Health() > 10 then draw.SimpleText("ON_STATUS ",“Trebuchet19”,150,0,Color(0,255,0,math.sin(CurTime()*math.abs(2))*155)) else draw.SimpleText("DAMAGE_ST ",“Trebuchet19”,150,0,Color(255,0,0,math.sin(CurTime()*math.abs(2))*155)) end
draw.SimpleText(“HP:”,“Trebuchet”,0,117,Color(0,255,0,255))
draw.RoundedBox(2,30,122,LocalPlayer():Health()*2.10,10,Color(0,255,0,255))
draw.SimpleText(“AR:”,“Trebuchet”,0,132,Color(0,0,255,255))
draw.RoundedBox(2,30,136,LocalPlayer():Armor()*2.10,10,Color(0,0,255,255))
end
hook.Add(“HUDPaint”, “Radar_Create”,Radar)

–Panel that’s handling the stuff.
usermessage.Hook(“dist_menu”,function()
local main = vgui.Create(“DFrame”)
main:Center()
main:MakePopup()
main:SetTitle(" “)
main:SetSize(200,100)
main:ShowCloseButton(true)
main.Paint = function()
draw.RoundedBox(6,0,0,main:GetWide(),20,color_black)
draw.RoundedBox(6,0,30,main:GetWide(),main:GetTall()/2,color_black)
draw.SimpleText(“HAS System Options”,“Trebuchet19”,35,0,color_white)
end
local dist = vgui.Create(“DNumSlider”,main)
dist:SetPos(20,30)
dist:SetWide(150)
dist:SetText(“Radar Distance”)
dist:SetMin(50)
dist:SetMax(600)
dist:SetValue(cam_dist)
dist.OnValueChanged = function(panel,value)
cam_dist = value
end
local but = vgui.Create(“DButton”,main)
but:SetText(”>")
but:SetSize(15,10)
but:SetPos(180,70)
but.DoClick = function()
cam_dist = dist:GetValue()
main:Close()
end
end)
[/lua]

You need to ensure that the variable is specified before you draw the panel, because even though that code block won’t run until you call the usermessage, the game still reads the code in that order.

I have also replaced your “LP()” with “LocalPlayer()”, wasn’t sure whether you had created an LP() function but didn’t include it in your post. Just change it back if you need to.

Thanks! I didn’t actually think of that, this should save loads of time now.