Script can't put SoundID into audio

  1. What do you want to achieve? To let the audio play music

  2. What is the issue? So the script should put audio asset ID in the audio, but when I did tests, the property section still shows soundID blank

  3. What solutions have you tried so far? I tried to remove anything unrelated to the script but did not help

The player gui is for the gui to show to player what song is currently being played


local player = game.Players.LocalPlayer.PlayerGui


local SongName = player.radio.radiopannel.SongName
local MarketPlaceService = game:GetService("MarketplaceService")

local Songs = {
	5409360995, 7023887630
	
}

local Song = script.Parent.Music

while true do
	for i = 1, #Songs do
		local Song = Songs[i]
		local SongInfo = MarketPlaceService:GetProductInfo(Song)

		Song.SoundId = "rbxassetid://" .. Song
		Song:Play()
		SongName.Visible = true
		SongName.Text = SongInfo.Name
	

		repeat wait() until not Song.IsPlaying
	end
end

I did a lot of tests, console didn’t show any errors and no matter what I delete from the script, change its position in the workspace, nothing really helped, the place for AudioID is still blank when doing tests

1 Like

You were changing the local Song to something else, heres a fixed script :slight_smile:

local player = game.Players.LocalPlayer
local playerGUI = player:WaitForChild("PlayerGui")
local MarketPlaceService = game:GetService("MarketplaceService")


local SongName = playerGUI.radio.radiopannel.SongName

local Songs = {
	"rbxassetid://5409360995"; 
	"rbxassetid://7023887630";
}

local Song = script.Parent.Music

while true do
	for i = 1, #Songs do
		local Song_ID = Songs[i]
		local SongInfo = MarketPlaceService:GetProductInfo(Song)

		Song.SoundId = Song_ID
		Song:Play()
		SongName.Visible = true
		SongName.Text = SongInfo.Name
	

		repeat wait() until not Song.IsPlaying
	end
end
1 Like

Hmmm…For some reason it still did not work, still the same reason, in property the AudioID place is blank when doing tests. I’ve looked at your script carfeully but still couldn’t find where went wrong :thinking:

Oh wait after a night of thinking, I finally had the solution, I was using Localscript and appearently that wouldn’t work for some reason, I put your script in a normal script now and it works! Thanks so much!