Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

'render distance' script needs some fixing?

Asked by 6 years ago
Edited 6 years ago
RunService:BindToRenderStep("Performance", 1, function()

-- For security reasons, most of the code has been taken out of this request for help.

            if distance < 1250 then

            --============================================--
                for _,g in pairs(Camera:GetChildren()) do
                    if g.Position == v.Position then
                    return
                    end
                end
            --============================================--

                v:Clone().Parent = Camera
            end
        end
    end
end)

The code you're seeing is designed to, as one could guess, put parts into the workspace at a certain range and then remove them if said range exceeds 1250 studs. It works- however it stops and returns end on the second "step" because the script doesn't want to duplicate the same part in the same spot over and over. Consequently though it will stop working until the player leaves the vicinity and every single part already rendered is outside of the range the script looks for. Then it just repeats the problem.

Any idea how to fix this? This is not my script. It belongs to a close friend who has provided permission to use it. I have already asked him, but he is taking admittedly a long time to respond with a fix... a week or two at least as of today. Any help would be great.

Edit: v = parts not in the workspace but cloned when needed to go into workspace. g = cloned parts already in the workspace.

0
what is g and v? ILikeTofuuJoe 1 — 6y
0
Give me a moment. Char187 0 — 6y
0
Updated with edit. Char187 0 — 6y

Answer this question