#Custom render distance script - Streaming enabled alternative not working
3 messages · Page 1 of 1 (latest)
local ignoredStagePrefix = "Stage "
local ignoredStageStart = 1
local ignoredStageEnd = 150
local originalProperties = {}
local function saveOriginalProperties(part)
originalProperties[part] = {
Transparency = part.Transparency,
CanCollide = part.CanCollide,
}
end
local function restoreOriginalProperties(part)
if originalProperties[part] then
part.Transparency = originalProperties[part].Transparency
part.CanCollide = originalProperties[part].CanCollide
end
end
local function updatePartProperties(part, isVisible)
if isVisible then
restoreOriginalProperties(part)
else
if not originalProperties[part] then
saveOriginalProperties(part)
end
part.Transparency = 1
part.CanCollide = false
end
end
local function shouldIgnore(part)
if part:IsA("Model") or part:IsA("Part") then
if part.Name:sub(1, #ignoredStagePrefix) == ignoredStagePrefix then
local stageNumber = tonumber(part.Name:sub(#ignoredStagePrefix + 1))
if stageNumber and stageNumber >= ignoredStageStart and stageNumber <= ignoredStageEnd then
return true
end
end
end
return false
end
local function updateParts()
local playerPosition = game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.HumanoidRootPart.Position
if not playerPosition then
return
end
for _, child in pairs(game.Workspace:GetChildren()) do
if not shouldIgnore(child) then
local distance = (playerPosition - child.Position).magnitude
local isVisible = distance <= 100
updatePartProperties(child, isVisible)
end
end
end
game:GetService("RunService").Stepped:Connect(function()
updateParts()
end)
MCUKING MACORNI