Sound is not loading

Hello
I was doing my Audio Visuliazer and I do command !play music id
But when I enter any ID it says


Here is my script

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		local Splitted = string.split(msg," ")
		if Splitted[1] == "!play" then
			workspace.Sound.SoundId = Splitted[2]
			workspace.Sound:Play()
		end
	end)
end)

Thank for any help

1 Like

Use:
rbxassetid://[ID]
Not just:
[ID]

Basically do:

workspace.Sound.SoundId = "rbxassetid://"..Splitted[2]
workspace.Sound:Play()

Roblox Studio auto-formats Asset IDs but scripts don’t.

Sorry but stil it’s dont work ignore that first error

Is it a valid sound ID? If it isn’t then it won’t work.

The IDs are valid, but the problem is that it’s a Roblox API issue rather than scripting issue.

If that’s the case then, I suggest to @vojta1587 that they wrap their code in pcall(). This will also prevent errors from being created if someone uses your command with invalid ids.

I don’t really know but I think it’s more of a temporary issue as of now. I believe waiting will suffice.


Rewriting it probably requires some use of ContentProvider as far as I know.

1 Like

I know using pcall.
ssssssssss

Even so, it means that the developer console won’t be bombarded by errors if someone decides to spam invalid IDs - in the case that they want to track an error, they could get the second returned variable of pcall when running the code.

Still don’t work sir
(30 char)

The pcall() is absolutely redundant in this case. This is more of a Roblox issue currently as previously stated and thus sound loading cannot be fixed until the endpoint is fixed.

Idk why is not loading right, That id i wanted play was same as first ID I set in Audio don’t work too.

My hyptotesis is that it doesnt work because; since you’re loading an Audio ID from the script, the audio takes some time to load but you play it instantly after inserting the id.
Try replacing the
workspace.Sound:Play()
with

task.spawn(function() -- So it doesnt yield the rest of the script
wait(workspace.Sound.IsLoaded)
workspace.Sound:Play()
end)

Fixed

Play is a function

If you have any questions, please ask me