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

LoD script not cooperating. Parts won't load within range of player?

Asked by 6 years ago
for _,v in pairs(LocalParts:GetChildren()) do

        if v:IsA("Part") or v:IsA("MeshPart") then

            local distance = Player:DistanceFromCharacter(v.Position)

            if distance < game.Lighting.FogEnd+750 then

                for _,g in pairs(Camera:GetChildren()) do

                    if g.Position == v.Position then
            return
                    end

                end

                v:Clone().Parent = Camera

            end

        end

end

This chunk gives me problems. When you load into the game and all the objects load in for the first time, it stops loading new parts until you leave the original distance specified at "if distance <". It's a BindToRenderStepped script. I have no idea what's going on here. But to describe the situation as indepth as I can, it has no problem unloading objects as you leave their range (another part of the script not shown), but for some odd reason if even a single object from 'LocalParts' is in the Camera, it stops loading new ones in even if they're not loaded in. If I try to remove the 'return' part it just duplicates parts from the folder into the Camera every single frame. I don't know what to do?

Note: PLEASE HELP. THIS HAS BOTHERED ME FOR WEEKS.

Answer this question