Here’s a drop-in ServerScript (e.g. put it in ServerScriptService) that will:
• Create two anchored 4×4×4 blocks
• Continuously cycle their colours (RGB rainbow) until clicked
• On click ➜ colour cycling stops & the block locks at solid red (inactive)
--[[
Rainbow Blocks
--------------
• Spawns two colour-cycling blocks.
• Clicking a block stops the cycle and turns it red (inactive).
]]
local RunService = game:GetService("RunService")
--------------------------------------------------------------------
-- Helper: Make one colour-changing block
--------------------------------------------------------------------
local function spawnRainbowBlock(blockName, position)
-- ► Physical part
local part = Instance.new("Part")
part.Name = blockName
part.Size = Vector3.new(4, 4, 4)
part.Anchored = true
part.Position = position
part.TopSurface = Enum.SurfaceType.Smooth
part.BottomSurface = Enum.SurfaceType.Smooth
part.Parent = workspace
-- ► Click detector
local clicker = Instance.new("ClickDetector")
clicker.Parent = part
-- ► State flag
local active = true
-- ► Colour-cycling coroutine
coroutine.wrap(function()
local hue = 0
while active do
-- Cycle through the HSV wheel
part.Color = Color3.fromHSV(hue, 1, 1)
hue = (hue + 0.0025) % 1 -- adjust speed here
RunService.Heartbeat:Wait()
end
end)()
-- ► When clicked → stop + turn red
clicker.MouseClick:Connect(function()
if active then
active = false
part.Color = Color3.new(1, 0, 0) -- pure red
end
end)
end
--------------------------------------------------------------------
-- Spawn two of them
--------------------------------------------------------------------
spawnRainbowBlock("RainbowBlock_A", Vector3.new( 0, 5, 0))
spawnRainbowBlock("RainbowBlock_B", Vector3.new(10, 5, 0))
Drag-and-drop this script into ServerScriptService (or run it in the command bar for quick testing).
Feel free to tweak size, positions, hue step size, or swap the coroutine for a task.spawn loop—Roblox is pretty flexible. Have fun! 🎮