Sound isn't loading

My goal is to load the intercom sound with the sfx variable. The name is changing to “Loading SFX” but isn’t going past that.

chimes=workspace.ASAS_Chimes
intercom=workspace.Intercom

local asas = {}

function asas.intercomSfx(line)
	local sfx=nil
	
	    -----Automatic Smart Announcement System chimes-----
	
	if line=="pm" then
		sfx=chimes.PM_PM_ASAS
	elseif line=="bap" then
		sfx=chimes.BAP_BAP_ASAS
		
		-----Military Announcement System chimes-----
	
	elseif line=="dbb" then
		sfx=chimes.DISTORTED_BAP_BAP_ASAS
	elseif line=="R" then
		sfx=chimes.REG_MAS
	elseif line=="H" then
		sfx=chimes.HIGH_MAS
	elseif line=="M" then
		sfx=chimes.MED_MAS
	elseif line=="M3" then
		sfx=chimes.MED_MAS_3T
	elseif line=="L" then
		sfx=chimes.LOW_MAS
	else
		warn(line,"intercom sfx not found")
	end
	intercom.Name="Loading SFX"
	intercom=sfx
	intercom.Loaded:Wait()
	intercom.Name="Intercom"
end

function asas.intercomTrack(line,sfx)
	if type(line)~="string" then
		warn("Line must be a string")
		return
	end
	local voice=workspace:FindFirstChild(line)
	if not voice then
		warn(line,"voice line not found")
		return
	end
	asas.intercomSfx(sfx)
	intercom.Ended:Wait()
	voice:Play()
end

return asas

how its being required & called:

ASAS=require(script.AutomaticSmartAnnouncementSystem)

ASAS.intercomTrack("kaboom0","H")

You’re yielding at intercom.Ended:Wait() but never calling :Play() on it

If it’s not going past Loading SFX then the problem is either in

intercome = sfx

or in

intercom.Loaded:Wait()

In this case the problem is clearely in intercom.Loaded:Wait() because the Loaded:Wait() event will yield infinitely if the sound is already loaded. So remove that line : )

1 Like

Thanks!, Script works perfectly now.

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