Using Net lib, error saying it got no value when sent to the server.

I have a Derma panel with a button that, when clicked, starts a net message to the server.
However, when I click the button, it gives me this error:



bad argument #2 to 'WriteUInt' (number expected, got no value)


This is the code I’m using to trigger the Net message:



changeTeamSpectators.DoClick = function()
	teamSelector:Close()
	changeTeam(2)
end


And this is the function the Net message is inside:



function changeTeam(teamNum)
	net.Start( "changeTeam" )
	net.WriteEntity(LocalPlayer())
	net.WriteUInt(teamNum)
	net.SendToServer()
end


I checked to make sure that the value was correct when it gets to the function with print(), and it is. So I can only assume I’m not getting something with the Net library.
I’ve checked the documentation, nothing about my code has stuck out to me. Thanks for any help.