Reverting visual changes

Sorry if the title sucks, but basically I’m trying to make this customization part of my shop and I wanna be able to visually display the thing to show the player what it would look like before buying however I need to obviously make sure to revert any changes when the player closes the shop. The code I currently have works however I have feeling it’s definitely not the best way to do this?

edit: Sorry for long code ;s also this is all on the client and so I know it’s obviously easily gonna be exploitable or most likely.

for _,button in pairs(customizeMenu:GetChildren()) do
	
	button.MouseButton1Click:Connect(function()
		
		local currentMenu = button.Name
		
		for item,data in pairs(customizations[button.Name]) do
			
			local button = Instance.new("TextButton")
			button.Name = item
			button.Text = item
			--button.Transparency = 0.9
			button.Font = "Arcade"
			button.TextSize = 30
			button.Parent = customizeShop.ScrollingFrame	
			
			button.MouseButton1Click:Connect(function()
				
				currentlySelected = button.Name
				
				if currentMenu == "Floor" then
					
					floor.Material = data.Material
					floor.Color = data.Color
					
					--I'm not sure the best way to do this, but gotta make sure to revert any of the visual changes
					spawn(function()
						repeat wait() until currentMenu ~= "Floor"
						--set the mat and color back to what it originally was
						floor.Material = currentFloorMat
						floor.Color = currentFloorColor
						
						--clear the text and disable the color picker
						colorPicker.R.Text = ""
						colorPicker.G.Text = ""
						colorPicker.B.Text = ""
						colorPicker.Visible = false
					end)
					
					--neon floor lets player choose color because cool B)
					--this will only show on the client to visually show the player what it would look like before buying it
					if currentlySelected == "Neon" then
						--no idea how this works, but... I mean alright I just know it like replaces stuff I guess
						local function removeLetters(text)
							return text:gsub("%D+", "")
						end

						colorPicker.Visible = true

						colorPicker.R:GetPropertyChangedSignal("Text"):Connect(function()
							if currentlySelected == "Neon" then
								colorPicker.R.Text = removeLetters(colorPicker.R.Text)
								floor.Color = Color3.fromRGB(colorPicker.R.Text,colorPicker.G.Text,colorPicker.B.Text)
							end
						end)
						
						colorPicker.G:GetPropertyChangedSignal("Text"):Connect(function()
							if currentlySelected == "Neon" then
								colorPicker.G.Text = removeLetters(colorPicker.G.Text)
								floor.Color = Color3.fromRGB(colorPicker.R.Text,colorPicker.G.Text,colorPicker.B.Text)
							end
						end)
						
						colorPicker.B:GetPropertyChangedSignal("Text"):Connect(function()
							if currentlySelected == "Neon" then
								colorPicker.B.Text = removeLetters(colorPicker.B.Text)
								floor.Color = Color3.fromRGB(colorPicker.R.Text,colorPicker.G.Text,colorPicker.B.Text)
							end
						end)
					else
						colorPicker.Visible = false
					end		
					
				elseif currentMenu == "Counter" then
					
					for _,v in pairs(counter:GetChildren()) do
						v.Material = data.Material
						v.Color = data.Color
					end
					
					spawn(function()
						repeat wait() until currentMenu ~= "Counter"
						for _,v in pairs(counter:GetChildren()) do
							v.Material = currentCounterMat
							v.Color = currentCounterColor
						end
					end)
				end
				
			end)
			
			closeButton.MouseButton1Click:Connect(function()
				for i,v in pairs(customizeShop.ScrollingFrame:GetChildren()) do
					if v:IsA("TextButton") then
						v:Destroy()
					end
				end
			end)
			
		end
	end)
end

Here’s a video/gif of what this code does

Looks good to me, but if you want to make it cooler, you could use a color wheel:
colour wheel.rbxl (18.7 KB)

For reference, you could loop the color of the floor to the color of the frame that changes color, or create a function that detects when the color of the frame changes using GetPropertyChangedSignal. (the loop is way easier)

Wow the colour wheel is definitely a lot nicer then what I had and probably easier instead of having the player find the RGB numbers they want lol. Not sure if I’ve implemented it properly, but it seems to work pretty good.