Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
AIexR32 11
4 years ago
Edited 4 years ago

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)
0
You could wrap your function with a pcall to check if it errors or not RealTinCan 217 — 4y
0
You could wrap your function with a pcall to check if it errors or not RealTinCan 217 — 4y

1 answer

Log in to vote
0
Answered by
AIexR32 11
4 years ago
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

Ad

Answer this question