Custom crosshair not moving with cursor

My custom crosshair won’t move with my cursor correctly and seems to be offset. It works perfectly in Studio, if I center the parent frame, everything moves with the frame being the center. However in-game this happens:


This is how my GUI is set up:
crosshairpic
And this is my code to move the crosshair to the cursor:

local runService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")
local gui = script.Parent
local crosshair = gui:WaitForChild("Crosshair")

runService.RenderStepped:Connect(function()
	local mouseLocation = userInputService:GetMouseLocation()
	crosshair.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
end)

Any help is appreciated.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local runService = game:GetService("RunService")
local gui = script.Parent
local crosshair = gui:WaitForChild("Crosshair")

mouse.Move:Connect(function()
    crosshair.Position = Udim2.new(0,Mouse.X,0,Mouse.Y)
end)
2 Likes