Color change won't stop

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Color change won’t stop
  2. What is the issue? Include screenshots / videos if possible!
    Color change won’t stop
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Breaking the loop
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
ChromaColorEvent.OnServerEvent:Connect(function(player, Status)
	
	local ChangeDelay = script.Parent:GetAttribute("ColorChangeDelay")

	local t = 3
	
	while wait(ChangeDelay) do
		
		if Status == true then
			
			local hue = tick() % t / t

			local color = Color3.fromHSV(hue,1,1)

			SpotLight.Color = color
			
		else
			
			SpotLight.Color = Color3.fromRGB(244, 255, 233)
			
		end
		
	end
		
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

If you are trying to get out of the while true loop use break to break the loop

I did use the break function or whatever it is but it didnt work

It seems your issue is that when you make another call to the OnServerEvent, it’ll remake the loop anyways, but I could be wrong, maybe try this?

ChromaColorEvent.OnServerEvent:Connect(function(player, Status)
	local ChangeDelay = script.Parent:GetAttribute("ColorChangeDelay")
	local t = 3
	
	while Status do
		local hue = tick() % t / t
		local color = Color3.fromHSV(hue,1,1)
		SpotLight.Color = color
        wait(ChangeDelay)
	end
	SpotLight.Color = Color3.fromRGB(244, 255, 233)
end)

If it doesn’t work, you may need to make an external variable to keep track of the status and check that for the loop instead

It doesnt work, so what do you mean by external variable?

Basically, make a variable that holds the current status of the spotlight outside of the remoteevent, something like local LightStatus = false, and inthe RemoteEvent, set LightStatus to the value given from Status, and make the While loop reference that instead

local LightStatus = false

ChromaColorEvent.OnServerEvent:Connect(function(player, Status)
	local ChangeDelay = script.Parent:GetAttribute("ColorChangeDelay")
	local t = 3
	
	LightStatus = Status
	
	while LightStatus do
		local hue = tick() % t / t
		local color = Color3.fromHSV(hue,1,1)
		SpotLight.Color = color
	end
	SpotLight.Color = Color3.fromRGB(244, 255, 233)
end)
ChromaColorEvent.OnServerEvent:Connect(function(player, Status)
   local ChangeDelay = script.Parent:GetAttribute("ColorChangeDelay")
   local t = 3
 
  
   if Status == true then
      while wait(ChangeDelay) do
         local hue = tick() % t / t
	     local color = Color3.fromHSV(hue,1,1)
	     SpotLight.Color = color
       end	
	else
		SpotLight.Color = Color3.fromRGB(244, 255, 233)	
	end		
end)

Maybe something like this could work.

Also, is there another way to make a rainbow part? Tween?

I believe so, but it would be a bit more complex than this, so I think it’s better of using this method instead

if so, can you please link me a yt video on how to do