Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to make "Unable to download sound data" error check?

i wanna make if error "Unable to download sound data" appears in console then my sound delete

local Event = game:GetService("ReplicatedStorage").Event

Event.PlaySound.OnServerEvent:Connect(function(Player, AssetId, Volume, Pitch)
	local Sound = instance.new("Sound")
	Sound.Parent = Player.Character.Radio
	Sound.Name = "Music"
	Sound.Volume = Volume or 0.5
	Sound.Pitch = Pitch or 0.5
	if typeof(AssetId) == "table" then
		Sound.SoundId = "http://www.roblox.com/asset/?id="..AssetId[math.random(1,#AssetId)]
	else
		Sound.SoundId = "http://www.roblox.com/asset/?id="..AssetId
	end
	Sound:Play()
end)

2 comments

0

You could wrap your function with a pcall to check if it errors or not

0

You could wrap your function with a pcall to check if it errors or not

1 answer

Event.Radio.PlaySound.OnServerEvent:Connect(function(Player, AssetId)
	local Sound = Player.Character.Radio.Music
	if typeof(AssetId) == "table" then
		Sound.SoundId = "http://www.roblox.com/asset/?id="..AssetId[math.random(1,#AssetId)]
	else
		Sound.SoundId = "http://www.roblox.com/asset/?id="..AssetId
	end
	Sound:Play()
end)

the error does not appear because I already added assetid to the existing sound

This discussion is preserved as it was. New answers, comments, and votes are closed.