local RGB = Color3.fromRGB()



--// Tween Preset Function
local newtween = function(obj, props, speed, ...)
    local info = TweenInfo.new(speed, ...);
    local tween = game:GetService("TweenService"):Create(obj, info, props);
    return tween:Play()
end

--// Local Button Variables
local button = script.Parent -- This is your local Button
local toggle = false -- This is your local toggle variable

--// Full Button Operation
button.MouseButton1Down:Connect(function()
    toggle = not toggle -- On click sets the local Toggle var to TRUE if starting at false; else back to FALSE.
    if toggle then -- If Toggle is TRUE then run newtween to WHITE.
        newtween(button,{BackgroundColor3 = RGB},0.3,Enum.EasingStyle.Sine,Enum.EasingDirection.In);
    else -- Else if Toggle is FALSE then run newtween to BLACK.
        newtween(button,{BackgroundColor3 = Color3.fromRGB(57, 57, 57)},0.3,Enum.EasingStyle.Sine,Enum.EasingDirection.Out);
    end
end)



while wait() do
	function color(X) return math.acos(math.cos(X*math.pi))/math.pi end

	value = 0

	if script.Parent.Parent.Parent.Parent.Menus.OptionsMenu["Top Bar"].RGB.Value == 1 then

		while true do
			wait(0.005)
			RGB = Color3.fromHSV(color(value),1,1)
			value = value + 0.005
		end	

	else  
		RGB = Color3.fromRGB(170, 85, 255)
	end
end

what this script does it change the background color of the button that you click to the current RGB value but it only does the value that is active when you click the button. is there a way to have the background change during and after the tweeting is done?