Need help with STOOLS

I’m making a tool that allows you to configure your speed with a slider and I don’t know how to output it. The tool does nothing. It only has the slider and I need it to output the value of the slider. How would I do this? Thanks in advance!



--[[
	Made by Metamorphics
	( STEAM_0:1:52851671 is the one and only author)
]]--

AddCSLuaFile()

TOOL.Category = "DC Powers Pack"
TOOL.Name = "Speedster Configuration"
TOOL.Command = nil
TOOL.ConfigName = ""

function TOOL:LeftClick( trace )
end

function TOOL:RightClick( trace )
end

function TOOL.BuildCPanel( panel )
	panel:AddControl("Slider", {
	    Label = "Speed",
	    Type = "Float",
	    Min = "500",
	    Max = "9000",

	})
end


AddControl is deprecated ( https://wiki.garrysmod.com/page/ControlPanel/AddControl ).

Try using a NumSlider instead (https://wiki.garrysmod.com/page/DForm/NumSlider)

It allows a convar to be changed. Perhaps you could create your own?

Try this:



function TOOL.BuildCPanel( panel )

	local slider = vgui.Create( "DNumSlider" )
	slider:SetText( "Speed" )
	slider:SetMin( 500 )
	slider:SetMax( 9000 )
	
	function slider:OnValueChanged( val ) -- called when the slider's value is changed
		print( val ) -- print it (for example)
	end
	
	panel:AddItem( slider )
	
end


I got the slider to work just fine with addcontrol? Why can’t I use it?

Because I don’t think there’s a way to modify the actual slider it adds since that function doesn’t seem to return anything

[editline]30th April 2016[/editline]

I just thought since you wanted to output the slider’s value, you need to be able to actually access the slider’s metatable