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

Anyone have a idea how to work this out i have asked multiple times?

local object = script.Parent
local position = object.Position
local debounce = false
local waittime = 0.5

script.Parent.MouseButton1Click:Connect(function()
    if debounce == false then
        debounce = true
        if script.Parent.Text == "On" then
            script.Parent.Text = "Off"
            object:TweenPosition(position,nil,nil,waittime)
            script.Parent.BackgroundColor3 = Color3.fromRGB(255,64,67)
        else
            script.Parent.Text = "On"
            object:TweenPosition(UDim2.new(0.714, 0, 0.102, 0),nil,nil,waittime)
            script.Parent.BackgroundColor3 = Color3.fromRGB(115,255,120)
        end
        wait(waittime)
        debounce = false
    end
end)

i have that script and i want when its on to turn a text to rainbow and when its off to turn it back to white the rainbow script is

function zigzag(X) return math.acos(math.cos(X*math.pi))/math.pi end

counter = 0

while wait(0.1)do
 script.Parent.BackgroundColor3 = Color3.fromHSV(zigzag(counter),1,1)
 
 counter = counter + 0.01
end

and the thing for what i want to turn rainbow is script.Parent.TextButton please respond quick thanks

1 answer

This does what you asked:

object = script.Parent
position = object.Position
debounce = false
waittime = 0.5
counter = 0
ison = false

script.Parent.MouseButton1Click:Connect(function()
	if debounce == false then
		debounce = true
		if object.Text == "On" then
			ison = false
			object.Text = "Off"
			object:TweenPosition(position, nil, nil, waittime)
			script.Parent.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
		else
			ison = true
			object.Text = "On"
			object:TweenPosition(UDim2.new(0.714, 0, 0.102, 0), nil, nil, waittime)
			object.BackgroundColor3 = Color3.fromRGB(115, 255, 120)
		end
		wait(waittime)
		debounce = false
	end
end)

spawn(function()
	while true do
		if ison == true then
			object.BackgroundColor3 = Color3.fromHSV(math.acos(math.cos(counter * math.pi)) / math.pi, 1, 1)
			counter = counter + 0.01
		end
		wait(.01)
	end
end)

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