local Allparts = {}
local OldParents = {}
local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local con,con2
local ChunkSize = 200
local lp
local Humanoid = Character:WaitForChild('Humanoid')
for i,v in ipairs(workspace.Map.Builds:GetDescendants()) do
if (v:IsA('BasePart')) then
table.insert(Allparts,v)
OldParents[v] = v.Parent
end
end
con2 = Humanoid.Died:Connect(function()
if (con) then
con:Disconnect()
end
if (con2) then
con2:Disconnect()
end
end)
con = Humanoid:GetPropertyChangedSignal('MoveDirection'):Connect(function()
for i,v in ipairs(Allparts) do
if (Player:DistanceFromCharacter(v.Position) > ChunkSize) then
if (lp ~= v) then
v.Parent = nil
lp = v
end
else
v.Parent = OldParents[v]
end
end
end)
I just made this simple chunk loading!
I want your thougs!
It’s simple, but, I think it’s efficient, what do you think?