You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Color change won’t stop
What is the issue? Include screenshots / videos if possible!
Color change won’t stop
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.
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
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)