How to automatically do a checkerboard pattern

Got a faster result, to where the second half of it isn’t as slow (due to the Y value starting at the very bottom and the X value being 0, it had to climb all the way up)

And came up with this weird result with TweenService and altering some variables:

New code here:

local TweenService = game:GetService("TweenService")
local HUD = script.Parent

local Amount = 12
local Sizing = math.ceil(HUD.AbsoluteSize.X / Amount)

local PreviousTile = nil
local Count = 0
local XStart = 0

task.wait(3) -- so I can watch the effect

local function NewInstance(Instance,Parent,Name,Properties)
	local i = Instance.new(Instance)
	if Name then
		i.Name = Name
	end
	if Properties then
		for p,v in pairs(Properties) do
			i[p]=v
		end
	end
	if Parent then
		i.Parent = Parent
	end
	return i
end

local function CreateTile(x,y,i)
	local Tile = NewInstance("Frame",HUD.Main,"Tile"..i,{
		BorderSizePixel = 0,
		BackgroundColor3 = (i%2==0 and Color3.fromRGB(240,240,240) or Color3.fromRGB(0,0,0)),
		Position = UDim2.new(0,Sizing*x,0,Sizing*y),
		Size = UDim2.new(0,0,0,0),
	})
	TweenService:Create(Tile,TweenInfo.new(0.6,Enum.EasingStyle.Back,Enum.EasingDirection.In),{
		Size = UDim2.new(0,Sizing,0,Sizing)
	}):Play()
	return Tile
end

local function CreateDiagonal(Y)
	PreviousTile = CreateTile(XStart,Y,Y)
	for i = XStart,Amount do
		PreviousTile = CreateTile(i,Y-i,Y)
		if PreviousTile.Position.Y.Offset == 0 then
			break
		end
		if PreviousTile.Position.Y.Offset >= Amount * Sizing then
			XStart += 1
		end
		task.wait(0.015)
	end
end

local function PlayTransition()
	PreviousTile = CreateTile(0,0,0)
	for i = 1,20 do
		CreateDiagonal(i)
		task.wait(0.015)
	end
end
PlayTransition()
print("Completed")
2 Likes

I’m starting to have a lot of fun with this (sorry, hopefully my last bump xD) @NinjoOnline

Added a rotation to the tween and made the tween take longer:

1 Like

This is really close. Only minor issue is the frames on the left always get doubled up. So it’s not a major issue, but could cause memory issues, and isn’t as performant. It also creates frames off screen too

Ah what, if you resize your screen after already pressing run I noticed it wouldn’t alight right due to how the Sizing variable is calculated. Maybe a UIScale or something could fix it. But that specific bug never happened to me (the one you showed).

Can’t get my most up-to date code because Roblox is down rn.

1 Like

I’m just using emulator, set to Fit to Window

Are you able to get your most up to date code now?? I’m messing around with it now, but I can’t figure out how to stop it from creating unneccesary tiles off the bottom of the screen. Means that the transition ‘slows’ down in a sense as it gets further, as it has to make all the tiles off the screen