"For i, v in pairs(folder:GetChildren) do" not working?

Hello! Basically what I want to happen is when you enter a part (which has been converted to a region3 via *https://create.roblox.com/store/asset/6245329519/ZonePlus?assetType=Model&externalSource=www this module. When entering the Region3 it is supposed to change the lighting effects and music, this does happen but the main problem is it isnt looping through the entire region folder of parts
image
It is only going through pharmacy and shelf area, not any of the other ones. Even the for loop only prints twice.

It is a really bizzare glitch and I have no idea how I can fix it. I am getting no errors, and the prints seem to not be helping.

local LocalPlayer = game.Players.LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()
local Camera = workspace.CurrentCamera
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local folder = workspace.SoundRegions
local tweenservice = game:GetService("TweenService")
local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("RegionGui").MainFrame
local currentarea = nil
local tweening = false

for i, v in pairs(folder:GetChildren()) do
	local zone = Zone.new(v)
	zone.Name = v.Name

	zone.playerEntered:Connect(function(player)
		if currentarea == zone.Name then
		else
			currentarea = zone.Name
			for i, v in pairs(script.SoundRegions:GetChildren()) do
				v:Stop()
			end
			script.SoundRegions[zone.Name]:Play()
			for i, v in pairs(game.Lighting:GetChildren()) do
				v:Destroy()
			end
			for i, v in pairs(script.SoundRegions[zone.Name]:GetChildren()) do
				if v.Name == "ClockTime" then
					game.Lighting.ClockTime = v.Value
				elseif v.Name == "CustomEffect" then
					local tag = nil
					if v.AlwaysStorming.Value == true then
						tag = "Always"
					else
						tag = "Global"
					end
					game:GetService("ReplicatedStorage").Events.WeatherChosen:Fire(v.Value, tag)
				elseif v.Name == "ReverbSoundEffect" then
					print("do nothing")
				else
					local clone = v:Clone()
					clone.Parent = game.Lighting
				end
			end
			if tweening == false then
				tweening = true
				gui.TitleText.Text = v.TitleText.Value
				gui.SubtitleText.Text = v.TitleText.SubtitleText.Value

				local info = TweenInfo.new(
					0.8,
					Enum.EasingStyle.Quad,
					Enum.EasingDirection.InOut
				)

				gui.Visible = true

				for i, v in pairs(gui:GetChildren()) do
					if v.Name == "SubtitleText" or v.Name == "TitleText" then
						local goal = {}
						goal.TextTransparency = 0

						local Tween = tweenservice:Create(v, info, goal)
						Tween:Play()
					else
						local goal = {}
						goal.Transparency = 0
						goal.Size = UDim2.new(0, 356,0, -6)

						local Tween = tweenservice:Create(v, info, goal)
						Tween:Play()
					end
				end
				wait(3.8)
				for i, v in pairs(gui:GetChildren()) do
					if v.Name == "SubtitleText" or v.Name == "TitleText" then
						local goal = {}
						goal.TextTransparency = 1

						local Tween = tweenservice:Create(v, info, goal)
						Tween:Play()
					else
						local goal = {}
						goal.Transparency = 0
						goal.Size = UDim2.new(0, 0,0, -6)

						local Tween = tweenservice:Create(v, info, goal)
						Tween:Play()
					end
				end
				wait(0.8)
				gui.Visible = false
				tweening = false
			end
		end
	end)
	print("region part loading"..v.Name)
	zone.playerExited:Connect(function(player)
	end)
end

You likely have StreamingEnabled turned on, so zones that are far away won’t be seen by the client until they get close. Try changing the Folder to a Model and make sure its ModelStreamingMode is set to Persistent, so it will always be streamed in by the client.

1 Like

Thank you! I can’t believe I forgot about StreamingEnabled (the bane of all client-side scripts fr fr)