All I am trying to do is have ink be directly where my mouse cursor is for convenience, but it has been driving me insane and I cannot find any possible way to fix it.
The issue is coming from the position of the newpixel
local function createPixel(position, color, player)
local newPixel = InkTemplate:Clone()
-- Adjust position to align directly with the cursor
newPixel.Position = UDim2.new(0, position[1] - newPixel.Size.X.Offset / 2, 0, position[2] - newPixel.Size.Y.Offset / 2)
newPixel.BackgroundColor3 = color
newPixel.Name = player.Name .. "_Pixel"
newPixel.Parent = CanvasFrame -- Ensure new pixels are parented to CanvasFrame
print("Created new pixel for player:", player.Name, "at position:", position, "with color:", color)
end
What I have tried so far is to see how/what could be the potential issue with my UDim2, and I tried to tweak it but it did not do much of a thing for it.
This is how the pixel will appear:
hello, thank you for the idea, however this did not correct the issue unfortunately. I also am confused as to what you mean by how one, I am getting the ‘position,’ when that already is shown, and two, as I show the pixels spawn and how that looks.
I feel like the AnchorPoint could be the problem, just compare the actual AbsolutePosition and the Position of the pixel, but I don’t really understand the purpose of centering drawn pixels, why do you need it?
the key is that your position must be interpreted as the center, not the top-left corner.
I also want it to have precision when I use the sketch board. even other apps like MS-Paint would operate in that same way as example.
No, in the client code where you send the position (MouseMoved) you’d have to do something like this:
....
if isDrawing then
x -= (pixel.Size.X.Offset / 2) --In your case this number is 10 so if you're not planning on changing the pixel sizes and keeping it as 20, you can just replace this calculation with x -= 10
y -= (pixel.Size.X.Offset / 2) --Same thing as above
--rest of code here
end
....