hi, im having issues with a localscript where for some reason the for _,v loop isnt working, it doesnt even print
code:
local RegionTextGui = script:WaitForChild("RegionText")
local RS = game:GetService("ReplicatedStorage")
local Skies = RS:WaitForChild("Skies")
local TweenService = game:GetService("TweenService")
local plr = game:GetService("Players").LocalPlayer
local PlayingSong = game:GetService("SoundService").PlayingSong
local ZonePlus = require(game:GetService("ReplicatedStorage").Modules.Zone)
local ZoneController = require(game:GetService("ReplicatedStorage").Modules.Zone.ZoneController)
local Zones = workspace.SoundsRegions
for _, zone_part in pairs(Zones:GetChildren()) do
local trigger = ZonePlus.new(zone_part)
trigger.playerEntered:Connect(function(player)
if player == plr then
TweenService:Create(PlayingSong, TweenInfo.new(.75), {Volume = 0}):Play()
wait(.75)
PlayingSong.SoundId = zone_part.Sound.SoundId
local nextVolume = zone_part.Sound.Volume
TweenService:Create(PlayingSong, TweenInfo.new(.5), {Volume = nextVolume}):Play()
end
end)
end
ZoneController.setGroup("SoundRegions", {
onlyEnterOnceExitedAll = true;
})
We know there is no zones to the local player because the table they printed was empty adding an if like this would just not run the code since this Isn’t a loop and Is a start of a script
I’m not 100% sure with what your problem exactly is, but the best reason this could be happening is if you try to index a table with no variables, it will break the script.
local t = {}
if #t > 0 then
print("table is not empty")
else
print("table is empty")
end
The issue here is that the client does not have a part not indexing the pairs loop doesn’t start because the table is empty even though there are Instances in the zones Instance so I am trying to figure out how to replicate it or why is it deleting / not synching with the server right Roblox made StramingEnabled enabled as default I am trying to test that
The issue is not in the for loop; it’s in local Zones = workspace.SoundsRegions. You’ve shown that a folder with that name exists, but there’s nothing in it. Can you check what’s inside while running the script? Possibly something is deleting the parts inside.
local Zones = workspace.SoundsRegions:GetChildren()
--"Zones" is now a table of children.
if #Zones > 0 then
print("not empty")
else
print("empty")
end