After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local TargetCursorGui = script.TargetCursorGui
local userinput = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local targetPart = workspace:WaitForChild("Target")
local RunService = game:GetService("RunService")
TargetCursorGui.Parent = plr.PlayerGui
RunService.Stepped:Connect(function()
local screenpos, Onscreen = camera:WorldToScreenPoint(targetPart.Position)
if Onscreen then
local screenposVector2 = Vector2.new(screenpos.X, screenpos.Y)
print("OnScreen")
print(screenposVector2)
TargetCursorGui.TargetCursor.Position = UDim2.fromOffset(screenpos.X, screenpos.Y)
else
local MouseLocation = userinput:GetMouseLocation()
TargetCursorGui.TargetCursor.Position = UDim2.fromOffset(MouseLocation.X, MouseLocation.Y)
end
end)
You don’t need to create a Vector2 value, just use screenpos.X and screenpos.Y they describe the offset from the top left hand corner of the screen in pixels to the point in world space, Z describes the depth.