Xray
Key RequiredUniversal

Xray

Universal ScriptValzxValzx 1.2K views 174 executesUpdated Dec 17, 2025
Unrated
00
Lua Script•64 lines (1893 chars)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local MAX_TRANSPARENCY = 0.9
local MIN_TRANSPARENCY = 0.0
local RADIUS = 50
local xrayEnabled = true

local function isPlayerPart(part)
    local character = part:FindFirstAncestorOfClass("Model")
    if character and character:FindFirstChildOfClass("Humanoid") then
        return true
    end
    return false
end

local xrayParts = {}
local function addPart(part)
    if part:IsA("BasePart") and not isPlayerPart(part) then
        table.insert(xrayParts, part)
    end
end

for _, part in ipairs(workspace:GetDescendants()) do
    addPart(part)
end

workspace.DescendantAdded:Connect(addPart)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.KeyCode == Enum.KeyCode.X then
        xrayEnabled = not xrayEnabled
    end
end)

RunService.RenderStepped:Connect(function()
    local character = player.Character
    if not character then return end
    local root = character:FindFirstChild("HumanoidRootPart")
    if not root then return end

    local playerPos = root.Position

    for _, part in ipairs(xrayParts) do
        if part and part.Parent then
            if xrayEnabled then
                local distance = (part.Position - playerPos).Magnitude
                local alpha
                if distance >= RADIUS then
                    alpha = MAX_TRANSPARENCY
                else
                    alpha = MIN_TRANSPARENCY + (MAX_TRANSPARENCY - MIN_TRANSPARENCY) * (distance / RADIUS)
                end
                part.LocalTransparencyModifier = alpha
            else
                part.LocalTransparencyModifier = 0
            end
        end
    end
end)

Features & Information

X - TOGGLE OFF/ON Yeah straight up Xray, the script isnt too hard to make though, Dont forget to like!
#universal#Xray#Cool#Perfect

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts