I’m trying to create a script that cycles through the colors of a rainbow, which in turn changes the color of an above-head-rank-nametag. I was able to successfully set up the nametag, however, I’m having trouble with the rainbow part.
While editing, I noticed an error message, however, I don’t understand how to fix it.
Current Script:
local CurrentColor = Color3.fromRGB(255,255,255)
------------------------------------------------------------------------
while true do
wait(0.25)
if NextColor == 1 then CurrentColor = Color3.fromRGB(148,0,211)
elseif NextColor == 2 then CurrentColor = Color3.fromRGB(75,0,130)
elseif NextColor == 3 then CurrentColor = Color3.fromRGB(0,0,255)
elseif NextColor == 4 then CurrentColor = Color3.fromRGB(0,255,0)
elseif NextColor == 5 then CurrentColor = Color3.fromRGB(255,255,0)
elseif NextColor == 6 then CurrentColor = Color3.fromRGB(255,127,0)
elseif NextColor == 7 then CurrentColor = Color3.fromRGB(255,0,0)
wait(0.25)
end
end
------------------------------------------------------------------------
while true do
script.Parent.Rank.TextColor3 = CurrentColor
script.Parent.Username.TextColor3 = CurrentColor
wait(0.5)
end
------------------------------------------------------------------------
if NextColor <= 7 then NextColor = NextColor + 1
else
NextColor = 1
end
In-studio screenshots:
(Note that black was never supposed to be a possible color.)
(Explorer Tree.)
(Script error that I don’t undertand.)
Notes
- Output shows no errors.
Thanks!
Wow, thanks for everyone’s help! I’m pretty new to scripting, and I learned a lot about Coroutines and tables!