I want to change a sound name by the song playing. I have all of my ids in one script and it changes a sound object to play according to that, but the problem is, is that the current track value I have displays the song name in a music player gui and only names it “Sound”.
Here is the script, ignore the fov script as thats for something else
local currentTrack = game.ReplicatedStorage.CurrentTrack
local CurrentCamera = workspace.CurrentCamera
local musicplayer = Instance.new("Sound",workspace)
music = {
"rbxassetid://3044286747", --here put the ids of the music
"rbxassetid://1256391355",
"rbxassetid://5480102561",
"rbxassetid://5024527209",
"rbxassetid://4492941290",
"rbxassetid://870242868",
"rbxassetid://1112109949",
"rbxassetid://6303331764",
"rbxassetid://2206587324",
"rbxassetid://5604871403",
"rbxassetid://5987864893",
"rbxassetid://534429024",
"rbxassetid://3616424949";
}
while true do
for i = 1, #music do
local currentmusic = music[i]
musicplayer.SoundId = currentmusic
musicplayer:Play()
currentTrack.Value = "..." -- displays the song playing in a music player gui
local ScreenShakeSettings = {
CameraMinFOV = 70,
CameraMaxFOV = 80,
CameraMaxVolume = 1500
}
connection = game:GetService("RunService").RenderStepped:connect(function()
local CurrentLoudness = musicplayer.PlaybackLoudness
local FOV = ScreenShakeSettings.CameraMinFOV + (ScreenShakeSettings.CameraMaxFOV - ScreenShakeSettings.CameraMinFOV) * (CurrentLoudness / ScreenShakeSettings.CameraMaxVolume)
if FOV > 0 and FOV < 130 then
CurrentCamera.FieldOfView = FOV
end
end)
currentTrack.Value = musicplayer.Name
musicplayer.Ended:Wait()
connection:Disconnect()
end
end```
I think what you could do is use MarketplaceService’s GetProductInfo function to return back a table of information to obtain, 1 being the Song Name you want to find
Keep in mind though that you’ll have to format the string to only return back the Int64 value
Try this?
local MPS = game:GetService("MarketplaceService")
local currentTrack = game.ReplicatedStorage.CurrentTrack
local CurrentCamera = workspace.CurrentCamera
local musicplayer = Instance.new("Sound",workspace)
music = {
"rbxassetid://3044286747", --here put the ids of the music
"rbxassetid://1256391355",
"rbxassetid://5480102561",
"rbxassetid://5024527209",
"rbxassetid://4492941290",
"rbxassetid://870242868",
"rbxassetid://1112109949",
"rbxassetid://6303331764",
"rbxassetid://2206587324",
"rbxassetid://5604871403",
"rbxassetid://5987864893",
"rbxassetid://534429024",
"rbxassetid://3616424949";
}
while true do
for i = 1, #music do
local currentmusic = music[i]
local SongID = string.match(currentmusic, "%d+")
local SongInfo = MPS:GetProductInfo(SongID)
musicplayer.SoundId = currentmusic
musicplayer.Name = SongInfo.Name
musicplayer:Play()
currentTrack.Value = "..." -- displays the song playing in a music player gui
local ScreenShakeSettings = {
CameraMinFOV = 70,
CameraMaxFOV = 80,
CameraMaxVolume = 1500
}
connection = game:GetService("RunService").RenderStepped:connect(function()
local CurrentLoudness = musicplayer.PlaybackLoudness
local FOV = ScreenShakeSettings.CameraMinFOV + (ScreenShakeSettings.CameraMaxFOV - ScreenShakeSettings.CameraMinFOV) * (CurrentLoudness / ScreenShakeSettings.CameraMaxVolume)
if FOV > 0 and FOV < 130 then
CurrentCamera.FieldOfView = FOV
end
end)
currentTrack.Value = musicplayer.Name
musicplayer.Ended:Wait()
connection:Disconnect()
end
end