For i,v in pairs() not working

got this error,
StarterPlayer.StarterPlayerScripts.Areas:26: attempt to index nil with ‘SoundId’

I made a typo, fixed:

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local TweenService = game:GetService("TweenService")

--//Modules
local ZonePlus = require(ReplicatedStorage.Modules.Zone)
local ZoneController = require(ReplicatedStorage.Modules.Zone.ZoneController)
ZoneController.setGroup("SoundRegions", {onlyEnterOnceExitedAll = true})

--//Variables
local PlayingSong = SoundService.PlayingSong
local Skies = ReplicatedStorage:WaitForChild("Skies")
local RegionTextGui = script:WaitForChild("RegionText")
local Zones = workspace.SoundsRegions

--//Functions
local function InitializeSoundRegion(part)
	print("Initialized Zone")
	local zone = ZonePlus.new(part)

	zone.localPlayerEntered:Connect(function(player)
		TweenService:Create(PlayingSong, TweenInfo.new(.75), {Volume = 0}):Play()
		task.wait(.75)

		PlayingSong.SoundId = part.Sound.SoundId
		
		local nextVolume = part.Sound.Volume
		TweenService:Create(PlayingSong, TweenInfo.new(.5), {Volume = nextVolume}):Play()
	end)
end

Zones.ChildAdded:Connect(InitializeSoundRegion)

for _, zone_part in ipairs(Zones:GetChildren()) do
	task.spawn(InitializeSoundRegion, zone_part)
end

Sorry you had to deal with 3 different people who had no clue what they were doing and were just trying to get a solution.

1 Like

I wasn’t trying to get a solution lol I was just suggesting OP to read the docs.

FYI, I’m not solely concentrating on trying to get a solution.

I guess I misread what you were actually trying to get fixed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.