Hey, I created a drawing system by using a SurfaceGui, while drawing it works but about the position, the draws spawns at the bottom left corner of the surface, (the surfacegui is on the baseplate), Heres what I did to position.
script.Parent.OnServerEvent:Connect(function(Player, X, Y) -- mouse x and y
local Ball = Instance.new('ImageLabel',workspace.Baseplate.SurfaceGui.MainFrame)
Ball.Size = UDim2.new(0,10,0,10)
Ball.Position = UDim2.new(0,workspace.Baseplate.Size.X - X,0,workspace.Baseplate.Size.Y - Y)
Ball.ImageTransparency = 1
Ball.BackgroundColor3 = Color3.new(1, 1, 1)
local UICorner = Instance.new('UICorner',Ball)
UICorner.CornerRadius = UDim.new(0,90)
end)
You’re using workspace.Baseplate.Size.X - X and workspace.Baseplate.Size.Y - Y , which is not the best way to position the ball on the surface. Instead, you should use X / workspace.Baseplate.Size.X and Y / workspace.Baseplate.Size.Y to get the relative position of the mouse click on the Baseplate surface, and then pass that to the first argument in UDim2.new for the position of the ball.
Edit:
script.Parent.OnServerEvent:Connect(function(Player, X, Y) -- mouse x and y
local Ball = Instance.new('ImageLabel', workspace.Baseplate.SurfaceGui.MainFrame)
Ball.Size = UDim2.new(0, 10, 0, 10)
Ball.Position = UDim2.new(X / workspace.Baseplate.Size.X, 0, Y / workspace.Baseplate.Size.Y, 0)
Ball.ImageTransparency = 1
Ball.BackgroundColor3 = Color3.new(1, 1, 1)
local UICorner = Instance.new('UICorner', Ball)
UICorner.CornerRadius = UDim.new(0, 90)
end)
If you want to position the ball on the surface of the Baseplate relative to the screen, you can use Mouse.X and Mouse.Y .
If you want to position the ball on the surface of the Baseplate relative to the world, you need to use Mouse.Hit.Position and convert it to the local coordinates of the Baseplate.
If the issue still persists, try printing the values of X and Y to the output to see what values they have, and ensure that they are within the expected range.
It looks like the Y position seems to always be 0, I tried positioning on a normal UI and it was on the top left corner of the screen, but too gone to the left.
Where the mouse was clicked has a X,Y,Z and its different than placing it in a UI thats a Vector2, since the Frame has 1,0,1,0 the size is different, the space to click is different and when changing places its different, I think thats what happening, but I don’t know whats the solution.
Since I have put to be 1,0,1,0, that Size is the total size of the Adornee in scale, which confuses more.