attempt to call method 'SteamID64' (a nil value)

I can’t use pl:SteamID64() even though it exists.

Maybe it is because I am using a local player? ( local pl = LocalPlayer() )
If it is, are there any other ways I can get around this? (This is client side)

Post your code, you’ve most likely done a mistake.


local pl = LocalPlayer()


function menuClasses()
	local Frame = vgui.Create( "DFrame" )
	Frame:SetTitle( "Choose A Class" )
	Frame:SetSize( 500, 500 )
	Frame:Center()
	Frame:MakePopup()
	Frame.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
		draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 150 ) ) -- Draw a red box instead of the frame
	end

	local Barbarian = vgui.Create( "DButton", Frame )
	Barbarian:SetText( "Barbarian" )
	Barbarian:SetTextColor( Color( 255, 255, 255 ) )
	Barbarian:SetPos( 100, 100 )
	Barbarian:SetSize( 100, 30 )
	Barbarian.Paint = function( self, w, h )
		draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue Button
	end
	Barbarian.DoClick = function()
		Frame:Close()
		SetData(pl:SteamID64(), "class", 0)
	end

	local GunMan = vgui.Create( "DButton", Frame )
	GunMan:SetText( "Gun Man" )
	GunMan:SetTextColor( Color( 255, 255, 255 ) )
	GunMan:SetPos( 400, 100 )
	GunMan:SetSize( 100, 30 )
	GunMan.Paint = function( self, w, h )
		draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue Button
	end
	GunMan.DoClick = function()
		Frame:Close()
		SetData(pl:SteamID(), "class", 1)
	end

	local Wizard = vgui.Create( "DButton", Frame )
	Wizard:SetText( "Wizard" )
	Wizard:SetTextColor( Color( 255, 255, 255 ) )
	Wizard:SetPos( 100, 400 )
	Wizard:SetSize( 100, 30 )
	Wizard.Paint = function( self, w, h )
		draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue Button
	end
	Wizard.DoClick = function()
		Frame:Close()
		SetData(pl:SteamID(), "class", 2)
	end

	local Ninja = vgui.Create( "DButton", Frame )
	Ninja:SetText( "Ninja" )
	Ninja:SetTextColor( Color( 255, 255, 255 ) )
	Ninja:SetPos( 400, 400 )
	Ninja:SetSize( 100, 30 )
	Ninja.Paint = function( self, w, h )
		draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue Button
	end
	Ninja.DoClick = function()
		Frame:Close()
		SetData(pl:SteamID(), "class", 3)
	end
end

the LocalPlayer() entity doesn’t exist before you spawn (which is when that code is run), so you should move “local pl = LocalPlayer()” inside the “menuClasses” function.