Making a drawing system

For some reason the frame isn’t cloning fast enough and it’s leaving gaps. Is there another way of doing this?

local replicatedStorage = game:GetService("ReplicatedStorage")
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local drawings = script.Parent.Drawings
local mark = replicatedStorage:WaitForChild("Mark")
local press = false
local x
local y

userInputService.InputBegan:Connect(function(key, processed)
	if processed then
		return false
	end
	if key.UserInputType == Enum.UserInputType.MouseButton1 then
		press = true
	end
end)

userInputService.InputEnded:Connect(function(key, processed)
	if processed then
		return false
	end
	if key.UserInputType == Enum.UserInputType.MouseButton1 then
		press = false
	end
end)

runService.RenderStepped:Connect(function()
	x = mouse.X / mouse.ViewSizeX
	y = mouse.Y / mouse.ViewSizeY
	if press == true then
		local newMark = mark:Clone()
		newMark.Position = UDim2.new(x, 0, y, 0)
		newMark.Parent = script.Parent
	end
end)

basically, you want to store the last mouse position, and draw a line between it and the current position.

I’m not sure how to do that with frames, but the pseudo code would work as follows:

local lastPos
function onMove()
    if not lastPos then lastPos = {mouse.X, mouse.Y}
    DrawLine(lastPos.X, lastPos.Y, mouse.X, mouse.Y) --Draw from last pos to new pos
end

My issue is that it won’t clone fast enough, I’ve tried something like that where I store the last position

Maybe you could resize and rotate the frames into lines, and have then link between the last point and the new point