Resetting settings weirdly changes the default to the prior settings

Ok so this is my settings menu where u can set keybinds.
image
If you press the reset key it SHOULD reset your settings to the default however there is one issue

If I reset keybinds once it works perfectly however if I reset them again It wont work.
image
This is what I do to reset the settings.
ProfileTemplate is a module script which is a table full of the default settings. It gets required at the top of the script and this is literally the ONLY time its actually called in this script.

When I print(ProfileTemplate[“Settings”]) instead of showing the default settings it shows the players settings they are trying to reset but it SHOULD be the default settings which is weird. I’ve tried using table.clone() I’ve tried requiring it inside of the remote event instead of at the top of the script and nothing has worked and I’m completely stumped.

Any help is greatly appreciated. Hopefully I explained well.

image
I’ve even tried doing this. I am now so confused on why it STILL doesn’t work.

Ok so turns out you cant clone dictionaries that have dictionaries inside of them UNLESS you use this function:


				local function deepCopy(original)
					local copy = {}
					for k, v in pairs(original) do
						if type(v) == "table" then
							v = deepCopy(v)
						end
						copy[k] = v
					end
					return copy
				end

and for some reason setting a table to another table overrides both tables instead of just the one your trying to set which is weird. Hopefully this can save someone else the pain I endured.