Drawing surface GUI issues

Hello,

I could use some help with a script I’m working on, I’m trying to make a smooth drawing script on a surface gui, so far everything’s worked brilliantly, but I’ve run into the issue where if my brush is set to small, you can see the circles and lines being out of sync, I’m guessing this is becouse of my math but I’m not sure, the drawing is updated firstly in a local script for smooth drawing, and then the frame is updated to the world.

Here’s the code that handles the creation of lines inbetween the dots

rs.RenderStepped:connect(function()
	if inFrame and clickActive then
		local DrawCircle = circleBrush:Clone()
		DrawCircle.Size = script.Parent.BrushCircleDecal.Size
		DrawCircle.Parent = script.Parent
		DrawCircle.Position = script.Parent.BrushCircleDecal.Position
		if oldDot then
			local startX, startY = oldDot.Position.X.Offset, oldDot.Position.Y.Offset
			local endX, endY = DrawCircle.Position.X.Offset, DrawCircle.Position.Y.Offset
			local line = circleLine:Clone()
			line.AnchorPoint = Vector2.new(0.5,0.5)
			line.Size = UDim2.new(0,(oldDot.AbsolutePosition - DrawCircle.AbsolutePosition).Magnitude,0,script.Parent.BrushCircleDecal.Size.X.Offset)
			line.Position = UDim2.new(0, (startX + endX) / 2, 0, (startY + endY) / 2)
			line.Rotation = math.atan2(endY - startY, endX - startX) * (180 / math.pi)
			line.Parent = script.Parent
		end
		oldDot = DrawCircle
	end
end)

Any help is appreciated, thanks!

2 Likes