
KeylessUniversal

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)No comments yet for this script.



