Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to turn off rainbow effect via textbutton?? FIXED!

so i tried aking rainbow gui that is customizable but i cant turn off the rainbow effect

 --// objects
    local Border = Instance.new("Frame")
    local Bordertop = Instance.new("Frame")
    
    --// properties
    rainbowbtn.MouseButton1Click:Connect(function()
    if rainbowbtn.Text == "Rainbow OFF" then
     
     rainbowbtn.Text = "Rainbow ON"
    
     function zigzag(X) return math.acos(math.cos(X*math.pi))/math.pi end
    
    counter = 0
    
    while wait(0.1) do 
     Border.BorderColor3 = Color3.fromHSV(zigzag(counter),1,1)
     Bordertop.BorderColor3 = Color3.fromHSV(zigzag(counter),1,1)
    
     counter = counter + 0.01
    end
     
     else
    
     rainbowbtn.Text = "Rainbow OFF"
     Bordertop.BorderColor3 = Color3.new(0, 1, 0.2)
     Border.BorderColor3 = Color3.new(0, 1, 0.2)
    
    end
    end)

its really annoying and i dont know how to turn it off every time i tried to tur it off it just started again at even faster speed

1 answer

The problem is that the While function executes forever

while wait(0.1) do 
        Border.BorderColor3 = Color3.fromHSV(zigzag(counter),1,1)
        Bordertop.BorderColor3 = Color3.fromHSV(zigzag(counter),1,1)
        counter = counter + 0.01
end

You should instead have a bool that controls if the loop is on or off.

while wait(0.1) do 
	if bool1 == true then
	   Border.BorderColor3 = Color3.fromHSV(zigzag(counter),1,1)		            		  				  
	   Bordertop.BorderColor3  = Color3.fromHSV(zigzag(counter),1,1)
       counter = counter + 0.01
    end
end

The entirety of your (now working) script

--// objects
   local Border = Instance.new("Frame")
   local Bordertop = Instance.new("Frame")
   
   --// properties
   bool1 = false
   rainbowbtn.MouseButton1Click:Connect(function()
   if rainbowbtn.Text == "Rainbow OFF" then
    
    rainbowbtn.Text = "Rainbow ON"
    bool1 = true
   
    function zigzag(X) return math.acos(math.cos(X*math.pi))/math.pi end
   
   counter = 0
    
    else
   
    rainbowbtn.Text = "Rainbow OFF"
    bool1 = false
    Bordertop.BorderColor3 = Color3.new(0, 1, 0.2)
    Border.BorderColor3 = Color3.new(0, 1, 0.2)
   
   end
   end)

   while wait(0.1) do 
   if bool1 == true then
    Border.BorderColor3 = Color3.fromHSV(zigzag(counter),1,1)
    Bordertop.BorderColor3 = Color3.fromHSV(zigzag(counter),1,1)
   
    counter = counter + 0.01
    end
   end

1 comment

1

thanks i tried this way but i did something wrong ty tho!

This discussion is preserved as it was. New answers, comments, and votes are closed.