Drawing not working

Hello. I am working on a drawing game, but, the drawing there doesn’t seem to work. At the first time, I tried to create a frame each time mouse.Move fired, but if the mouse moved to fast, then it wouldn’t work. I now tried another method, which is to basically fill frames between 2 points of where the mouse moves, but this doesn’t seem to work neither. Here is my current code:

function on_Move()
	local differenceX = math.abs(mouse.X - lastMousePosition.X.Offset);
	local differenceY = math.abs(mouse.Y - lastMousePosition.Y.Offset);
	lastMousePosition = UDim2.new(0, mouse.X, 0, mouse.Y)
	if not isOn then return end;
	if not isDown then return end;
	if not frame.Parent.CanDraw.Value then return end;
	local clone = draw:Clone();
	clone.Size = UDim2.new(0.014 * (script.Parent.DrawSize.Value), 0, 0.025 * (script.Parent.DrawSize.Value), 0)
	clone.Parent = frame;
	if math.sign(differenceX) == -1 then
		for i = lastMousePosition.X.Offset, differenceX, -50 do
			clone.Position = UDim2.new(0, differenceX, 0, frame.Position.Y.Offset)
		end
	end

	if math.sign(differenceX) == 1 then
		for i = lastMousePosition.X.Offset, differenceX, 50 do
			clone.Position = UDim2.new(0, differenceX, 0, frame.Position.Y.Offset)
		end
	end

	if math.sign(differenceY) == -1 then
		for i = lastMousePosition.X.Offset, differenceX, -50 do
			clone.Position = UDim2.new(0, differenceX, 0, frame.Position.Y.Offset)
		end
	end

	if math.sign(differenceY) == 1 then
		for i = lastMousePosition.Y.Offset, differenceY, 50 do
			clone.Position = UDim2.new(0, differenceX, 0, frame.Position.Y.Offset)
		end
	end
end

mouse.Move:Connect(on_Move)
1 Like