I'm trying to make a drawing system for my game, and I came up with this script. When I try and use it though, the gui's (ink) position is set a decent amount off from where the mouse is.
local RunService = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
RunService.RenderStepped:Connect(function()
local mousepos = UIS:GetMouseLocation()
if game.Players.LocalPlayer.MousePressed.Value == true then
local ink = game.ReplicatedStorage.Ink:Clone()
local relativePosition = mousepos - ink.AbsolutePosition
ink.Parent = plr.PlayerGui.Canvas.Ink.Canvas
ink.Position = UDim2.fromOffset(relativePosition.X, relativePosition.Y)
ink.Visible = true
print("x")
end
end)
** You are now Level 8! **