Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Find the connected Player Detector peripheral
- local detector = peripheral.find("playerDetector")
- if not detector then
- error("Player Detector not found. Please ensure it is connected.")
- end
- -- Define the detection range (e.g., 10 blocks)
- local range = 10
- -- Retrieve the list of players within the specified range
- local playersInRange = detector.getPlayersInRange(range)
- -- Check if any players are detected
- if #playersInRange == 0 then
- print("No players detected within range.")
- else
- -- Iterate through the list of detected players and display their information
- for _, player in ipairs(playersInRange) do
- local playerName = player.name or "Unknown"
- local playerX = player.x or "N/A"
- local playerY = player.y or "N/A"
- local playerZ = player.z or "N/A"
- print(string.format("Player: %s -- Coordinates: (X: %s, Y: %s, Z: %s)", playerName, playerX, playerY, playerZ))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement