-- Screen Coordinate Measurement System
-- This script displays the X and Y coordinates wherever you click on your screen

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

-- Create a ScreenGui to hold our coordinate displays
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "ScreenCoordinateSystem"
screenGui.ResetOnSpawn = false
screenGui.Parent = player.PlayerGui

-- Function to create a coordinate marker
local function createCoordinateMarker(position)
    -- Create a frame for the marker
    local marker = Instance.new("Frame")
    marker.Size = UDim2.new(0, 8, 0, 8)
    marker.Position = UDim2.new(0, position.X - 4, 0, position.Y - 4)
    marker.BorderSizePixel = 0
    marker.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- Red dot
    marker.Parent = screenGui
    
    -- Add crosshair lines
    local horizontalLine = Instance.new("Frame")
    horizontalLine.Size = UDim2.new(0, 20, 0, 1)
    horizontalLine.Position = UDim2.new(0, -6, 0, 3.5)
    horizontalLine.BorderSizePixel = 0
    horizontalLine.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
    horizontalLine.Parent = marker
    
    local verticalLine = Instance.new("Frame")
    verticalLine.Size = UDim2.new(0, 1, 0, 20)
    verticalLine.Position = UDim2.new(0, 3.5, 0, -6)
    verticalLine.BorderSizePixel = 0
    verticalLine.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
    verticalLine.Parent = marker
    
    -- Create coordinate label
    local xCoord = math.floor(position.X + 0.5)
    local yCoord = math.floor(position.Y + 0.5)
    
    local coordinateLabel = Instance.new("TextLabel")
    coordinateLabel.Size = UDim2.new(0, 120, 0, 20)
    coordinateLabel.Position = UDim2.new(0, 10, 0, 10)
    coordinateLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
    coordinateLabel.BackgroundTransparency = 0.5
    coordinateLabel.BorderSizePixel = 0
    coordinateLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
    coordinateLabel.Text = "X: " .. xCoord .. ", Y: " .. yCoord
    coordinateLabel.TextSize = 14
    coordinateLabel.Parent = marker
    
    -- Keep track of this marker's data
    marker:SetAttribute("X", xCoord)
    marker:SetAttribute("Y", yCoord)
    
    return marker
end

-- Function to create coordinates display at top of screen
local function createCoordinatesDisplay()
    local frame = Instance.new("Frame")
    frame.Name = "CurrentCoordinates"
    frame.Size = UDim2.new(0, 200, 0, 40)
    frame.Position = UDim2.new(0.5, -100, 0, 10)
    frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
    frame.BackgroundTransparency = 0.5
    frame.BorderSizePixel = 0
    frame.Parent = screenGui
    
    local label = Instance.new("TextLabel")
    label.Name = "CoordinatesText"
    label.Size = UDim2.new(1, 0, 1, 0)
    label.BackgroundTransparency = 1
    label.TextColor3 = Color3.fromRGB(255, 255, 255)
    label.Text = "Mouse Position: X: 0, Y: 0"
    label.TextSize = 16
    label.Parent = frame
    
    return frame
end

-- Create the coordinates display
local coordinatesDisplay = createCoordinatesDisplay()

-- Array to store all markers
local markers = {}

-- Track mouse movement for real-time coordinate display
UserInputService.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseMovement then
        local mousePos = UserInputService:GetMouseLocation()
        local displayLabel = coordinatesDisplay.CoordinatesText
        displayLabel.Text = "Mouse Position: X: " .. math.floor(mousePos.X + 0.5) .. ", Y: " .. math.floor(mousePos.Y + 0.5)
    end
end)

-- Handle mouse clicks to add coordinate markers
UserInputService.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        -- Only place marker if not clicking on UI elements
        if not UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then
            return
        end
        
        local mousePos = UserInputService:GetMouseLocation()
        local marker = createCoordinateMarker(mousePos)
        table.insert(markers, marker)
    elseif input.KeyCode == Enum.KeyCode.C then
        -- Clear all markers when pressing C
        for _, marker in ipairs(markers) do
            marker:Destroy()
        end
        markers = {}
    end
end)

-- Create instructions text
local instructionsFrame = Instance.new("Frame")
instructionsFrame.Size = UDim2.new(0, 250, 0, 60)
instructionsFrame.Position = UDim2.new(0, 10, 0, 60)
instructionsFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
instructionsFrame.BackgroundTransparency = 0.7
instructionsFrame.BorderSizePixel = 0
instructionsFrame.Parent = screenGui

local instructionsText = Instance.new("TextLabel")
instructionsText.Size = UDim2.new(1, -10, 1, -10)
instructionsText.Position = UDim2.new(0, 5, 0, 5)
instructionsText.BackgroundTransparency = 1
instructionsText.TextColor3 = Color3.fromRGB(255, 255, 255)
instructionsText.TextSize = 14
instructionsText.TextXAlignment = Enum.TextXAlignment.Left
instructionsText.TextYAlignment = Enum.TextYAlignment.Top
instructionsText.Text = "Click anywhere to place a coordinate marker\nPress C to clear all markers"
instructionsText.Parent = instructionsFrame

-- Function to hide/show the UI with LeftAlt
local uiVisible = true
UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftAlt then
        uiVisible = not uiVisible
        screenGui.Enabled = uiVisible
    end
end)

print("Screen Coordinate Measurement System loaded!")
print("Click to place markers, press C to clear, and LeftAlt to toggle UI")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: