2D Painting White Board system functions

Their has been no results found on the developer forum about this so I wanted to make this or on YouTube So I don’t really have a code but I got a code from a drawing thing I have I’m thinking of having a fill section so you draw a shape and fill it in with a selected colour code i have so far:

–Service
local player = game:GetService(“Players”).LocalPlayer
local mouse = player:GetMouse()

–Gui
local frame = script.Parent
local ClearButton = script.Parent:WaitForChild(“ClearButton”)

–Value
local dotColor = Color3.new(0,0,0)
local pressed = false
local x,y,dot

mouse.Button1Down:Connect(function()
pressed = true
end)

mouse.Button1Up:Connect(function()
pressed = false
end)

game:GetService(“RunService”).RenderStepped:Connect(function()
x = mouse.X; y = mouse.Y
if pressed == true then
dot = Instance.new(“Frame”)
dot.Name = “Dot”
dot.BorderSizePixel = 0
dot.Parent = frame
dot.BackgroundColor3 = dotColor
dot.Size = UDim2.new(0, 6, 0, 6)
dot.Position = UDim2.new(0, x - frame.AbsolutePosition.X, 0, y - frame.AbsolutePosition.Y)
end
end)

ClearButton.MouseButton1Click:Connect(function()
for i, q in pairs(frame:GetChildren()) do
if q.Name == “Dot” then
q:Destroy()
end
end
end)

for number,buttons in pairs(frame:GetChildren()) do --get all things
if buttons:IsA(“TextButton”) and buttons:GetAttribute(“dotColor”) then – filter buttons with attribute named dotcolor
buttons.MouseButton1Up:Connect(function()
dotColor = buttons:GetAttribute(“dotColor”) --change dotcolor to color in attribute
end)
end
end