I want to make a color block game since they are very popular on roblox right now. I currently have a round system but need a way to make the color block system e.g. making different colors dissapear except for one color each time and displaying this in a gui. Does anyone have any tips on how I can achieve this.
local chosenColor = Color3.fromRGB(255,255,255)
for _, block in blocksFolder:GetChildren() do
if block.Color ~= chosenColor then
block.Transparency = 1
block.CanCollide = false
end
end
task.wait(5)
for _, block in blocksFolder:GetChildren() do
if block.Color ~= chosenColor then
block.Transparency = 0
block.CanCollide = true
end
end
Something as simple as this would work. I’m sure there’s ways for this to be more efficient though.
(edit: got the conditions the wrong way round, sorry)
Also, this’ll only “run” once because the chosen colour is fixed. if you want it to go multiple times, use the randomcolour stuff i posted above.
I know you came up with a solution but I was doing something like what your doing that uses what A lot of people above said. I thought I would share as it does have a fade animation, though not requested, but if you want it here it is:
local FolderOfParts = game.Workspace.ColorChangingParts
local Colors = {Color3.fromHex("#00ff00"), Color3.fromHex("#f8f8f8"), Color3.fromHex("#0000ff")}
local function FadeAnimation(part, TransparentNum)
local TweenService = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
TweenService:Create(part, info, {Transparency = TransparentNum}):Play()
end
while true do
task.wait(5)
local PickRandom = Colors[math.random(1, #Colors)]
for i, ColorParts in ipairs(FolderOfParts:GetChildren()) do
if ColorParts:IsA("BasePart") and ColorParts.Color ~= PickRandom then
ColorParts.CanCollide = false
coroutine.wrap(FadeAnimation)(ColorParts, 1)
end
end
task.wait(5)
for i, ColorParts in ipairs(FolderOfParts:GetChildren()) do
if ColorParts:IsA("BasePart") then
ColorParts.CanCollide = true
coroutine.wrap(FadeAnimation)(ColorParts, 0)
end
end
end