GUI Not Saving Table on Net Receive

I have my GUI setup to receive a table named RAS.Config, here is the code for that:



net.Receive("RASOpenConfigEditor", function()
		tbl = net.ReadTable()

		tfpick1 = tobool(tbl.AntiSpamming)
		tfpick2 = tobool(tbl.Chat.Enabled)
		tfpick3 = tobool(tbl.Prop.Enabled)
		tfpick4 = tobool(tbl.Sent.Enabled)
		tfpick5 = tobool(tbl.Effect.Enabled)
		tfpick6 = tobool(tbl.Ragdoll.Enabled)
		tfpick7 = tobool(tbl.Vehicle.Enabled)
		tfpick8 = tobool(tbl.Npc.Enabled)

		local function check(tfpick)
			if tfpick then
				return 1
			else
				return 0
			end
			return 0
		end
--Skip a bunch of GUI stuff

sbutton.DoClick = function()
			menu:Remove()
			net.Start("RASSaveConfigOptions")
				net.WriteBool(Dermacheckbox1:GetChecked())
				net.WriteBool(Dermacheckbox2:GetChecked())
				net.WriteFloat(DermaNumSlider1:GetValue())
				net.WriteBool(Dermacheckbox3:GetChecked())
				net.WriteFloat(DermaNumSlider1:GetValue())
				net.WriteBool(Dermacheckbox4:GetChecked())
				net.WriteFloat(DermaNumSlider3:GetValue())
				net.WriteBool(Dermacheckbox5:GetChecked())
				net.WriteFloat(DermaNumSlider4:GetValue())
				net.WriteBool(Dermacheckbox6:GetChecked())
				net.WriteFloat(DermaNumSlider5:GetValue())
				net.WriteBool(Dermacheckbox7:GetChecked())
				net.WriteFloat(DermaNumSlider6:GetValue())
				net.WriteBool(Dermacheckbox8:GetChecked())
				net.WriteFloat(DermaNumSlider7:GetValue())
			net.SendToServer()


Then another file is setup to receive the net messages:



net.Receive("RASSaveConfigOptions", function(len, ply)
	if RAS.HasPerms( ply ) then
		local answer1 = tostring( net.ReadBool() )
		local answer2 = tostring( net.ReadBool() )
		local answer3 = tostring( net.ReadFloat() )
		local answer4 = tostring( net.ReadBool() )
		local answer5 = tostring( net.ReadFloat() )
		local answer6 = tostring( net.ReadBool() )
		local answer7 = tostring( net.ReadFloat() )
		local answer8 = tostring( net.ReadBool() )
		local answer9 = tostring( net.ReadFloat() )
		local answer10 = tostring( net.ReadBool() )
		local answer11 = tostring( net.ReadFloat() )
		local answer12 = tostring( net.ReadBool() )
		local answer13 = tostring( net.ReadFloat() )
		local answer14 = tostring( net.ReadBool() )
		local answer15 = tostring( net.ReadFloat() )

		RAS.Config.AntiSpamming = answer1
		RAS.Config.Chat.Enabled = answer2
		RAS.Config.Chat.Delay = answer3
		RAS.Config.Prop.Enabled = answer4
		RAS.Config.Prop.Delay = answer5
		RAS.Config.Sent.Enabled = answer6
		RAS.Config.Sent.Delay = answer7
		RAS.Config.Effect.Enabled = answer8
		RAS.Config.Effect.Delay = answer9
		RAS.Config.Ragdoll.Enabled = answer10
		RAS.Config.Ragdoll.Delay = answer11
		RAS.Config.Vehicle.Enabled = answer12
		RAS.Config.Vehicle.Delay = answer13
		RAS.Config.Npc.Enabled = answer14
		RAS.Config.Npc.Delay = answer15
		RAS.UpdateConfig()
		RAS.ChatPrint( "Config options have been saved!", ply  )
	end
end)


The commands seem to change the table but it doesn’t effect the rest of the addon and i don’t know why.

are you net.receiving in HUDPaint?

if you are, move your net.receive elsewhere (into a function that isn’t called per frame)

Nope

Are you’re sure the table IS meant to affect other stuff in the addon?

Also, I noticed you were doing



menu:Remove()


Are you sure all the sliders and checkboxes aren’t parented to the menu? If they are, they’d be removed as well, making GetValue not work

Yes they all effect the addon. Tomorrow I’ll try using menu:Remove() after the net messages.

You have 15 useless variables and the code in general is an unstructured mess with the precise ordering of reading/writing the variables. Find a better way of doing the networking…like keeping a table of the changes made to the config in

DNumSlider:OnValueChanged and

DCheckBox:OnChange so you don’t have to read/write a bunch of useless data. Or you can immediately send the change in those callbacks.