I made a script which can smoothly go from one colour to another and display it with parts.
https://gyazo.com/17813170705c174b97cf7862459f357f
wait(1) local group = Instance.new("Model", workspace) group.Name = "gradient" local start = Color3.new(0,0,0) local End = Color3.new(0,1,0) local size = 100 for x=1, size, 1 do wait() for y=1, size, 1 do local point = Instance.new("Part") point.Anchored = true point.Size = Vector3.new(.1,.1,.1) point.Position = Vector3.new(x/10, 1, y/10) point.Color = start:lerp(End, x/size) point.CanCollide = false point.Name = (x .. ":" .. y) point.Parent = group end end
How can I make this smoothly go through all the colours of the rainbow rather than just 2 colours?
Use Tweens on the color value. Here's an example that goes from white to black:
local TweenService = game:GetService("TweenService") local part = script.Parent local openGoal = {} openGoal.Color = Color3.fromRGB(0,0,0) -- change this to ending RGB value (black in this case) local closeGoal = {} closeGoal.Color = Color3.fromRGB(255,255,255) -- change this to starting RGB value (white in this case local tweenInfo = TweenInfo.new(4) -- how long the tween will last in seconds local open = TweenService:Create(part, tweenInfo, openGoal) local close = TweenService:Create(part, tweenInfo, closeGoal) function onClicked() if part.Color == Color3.fromRGB(255,255,255) then open:Play() end if part.Color == Color3.fromRGB(0,0,0) then close:Play() end end script.Parent.ClickDetector.MouseClick:connect(onClicked)