Hi! Thanks You Both For Answer This Post
I can make flood fill now
here the script if someone needed
function paintbucket(Center)
local CenterColor = Center.BackgroundColor3
local digits = { }
if Center and CenterColor ~= preview.BackgroundColor3 then
for occurrence in (Center.Name):gmatch("%d+") do
table.insert(digits, tonumber(occurrence))
end
local xx, yy = digits[1], digits[2]
local PixelA = PaintFrame:FindFirstChild("Pixel"..xx.."x"..yy)
local function FloodFill(PixelB, x, y)
task.wait(0.01) --Delay
if PixelB and PixelB.BackgroundColor3 == CenterColor then
PixelB.BackgroundColor3 = preview.BackgroundColor3
if PaintFrame:FindFirstChild("Pixel"..(x-1).."x"..y) then
PixelA = PaintFrame:FindFirstChild("Pixel"..(x-1).."x"..y)
xx, yy = x+1, y
task.spawn(function() FloodFill(PixelA, x-1, y) end)
end
if PaintFrame:FindFirstChild("Pixel"..(x+1).."x"..y) then
PixelA = PaintFrame:FindFirstChild("Pixel"..(x+1).."x"..y)
xx, yy = x-1, y
task.spawn(function() FloodFill(PixelA, x+1, y) end)
end
if PaintFrame:FindFirstChild("Pixel"..x.."x"..y-1) then
PixelA = PaintFrame:FindFirstChild("Pixel"..x.."x"..y-1)
xx, yy = x, y+1
task.spawn(function() FloodFill(PixelA, x, y-1) end)
end
if PaintFrame:FindFirstChild("Pixel"..x.."x"..y+1) then
PixelA = PaintFrame:FindFirstChild("Pixel"..x.."x"..y+1)
xx, yy = x, y-1
task.spawn(function() FloodFill(PixelA, x, y+1) end)
end
end
end
FloodFill(PixelA, xx, yy)
else
print("center color and color select are same")
end
end
here how to use
paintbucket(GUIFrame)
Canvas Create Script (Run in Command Bar)
local Frame = game.StarterGui.PixelPaint.Frame
local posi = UDim2.new(-0.03125, 0,0, 0)
local posi2 = UDim2.new(0, 0,0, 0)
local Y = 1
for x = 1, 32 do
for i = 1, 32 do
local Pixel = Instance.new("TextButton", Frame)
Pixel.Size = UDim2.new(0.03125, 0,0.03125, 0)
posi = posi+UDim2.new(0.03125, 0,0, 0)
Pixel.Position = posi
Pixel.BackgroundColor3 = Color3.fromRGB(255,255,255)
Pixel.Text = " "
Pixel.Name = "Pixel"..(i).."x"..Y
if i == 32 then
posi = UDim2.new(-0.03125, 0,0, 0)
end
end
posi2 = posi2+UDim2.new(0, 0,0.03125, 0)
posi = posi+posi2
Y = Y+1
end
thanks you so much!