How could I make a script that changes the StreamingEnabledDistance, like for high-end and low-end PCs.
I looked around but didn’t find any good solutions.
What do you recommend?
How could I make a script that changes the StreamingEnabledDistance, like for high-end and low-end PCs.
I looked around but didn’t find any good solutions.
What do you recommend?
It’s not possible to change StreamingEnabled properties at runtime, so you would probably have to create your own un-rendering function using something like this:
Keep in mind that I am not sure how well it’s going to work in terms of performance.
local parts = {}
local unloadedParts = {}
local distanceToUnRender = 1000
local character = game:GetService('Players').LocalPlayer.Character
for i,v in pairs(workspace:GetChildren()) do -- put this where most of your map's objects are, your models will have to have a bounding box, and the PrimaryPart has to be the bounding box though.
if v:IsA('BasePart') or v:IsA('Model') then
table.insert(parts, v)
end
end
local function testToUnRender() -- tests each part in the parts table to decide whether to un-render it or not
for i,v in pairs(parts) do
local testingPart
if v:IsA('Model') then
testingPart = v.PrimaryPart
elseif v:IsA('BasePart') then
testingPart = v
end
local mag = (testingPart.Position - Character.HumanoidRootPart.Position).Magnitude -- gets the distance between you and the testingPart.
if mag => distanceToUnRender then
v.Parent = nil -- hides the part
end
end
local function testToRender()
for i,v in pairs(unloadedParts)
local testingPart
if v:IsA('Model') then
testingPart = v.PrimaryPart
elseif v:IsA('BasePart') then
testingPart = v
end
local mag = (testingPart.Position - character.HumanoidRootPart.Position).Magnitude
if mag =< distanceToUnRender then
v.Parent = workspace -- wherever your parts should return to
table.remove(unloadedParts, i)
end
end
end
character.HumanoidRootPart:GetPropertyChangedSignal('Position'):Connect(testToUnRender)
character.HumanoidRootPart:GetPropertyChangedSignal('Position'):Connect(testToRender) -- recalculates whenever the player moves
Robloxs intent is that it will do this automatically
“StreamingTargetRadius” is the radius you want on a computer that can handle the full load
“SteamingMinRadius” is the minimum radius the lowest quality computers will run on
Any value in between will be chosen by roblox automatically