I could see how this could help, but I have quite a couple audio IDs and I would not want to repeat code over and over and over just for one audio ID each piece of code, lol. Are there any other methods to get the names of the audios, or no?
local function getAudioName(id: number): string
local success, output = pcall(function()
-- return the product's info
return game:GetService("MarketplaceService"):GetProductInfo(id)
end)
if success then
return output.Name -- returns the item's name in the marketplace
else
warn(output) -- if there was an issue, this sends it to the console so you can see what the problem is
end
return "[ unknown ]" -- default name if the actual name can't be fetched
end
print(getAudioName(9112854440)) -- prints "Rain On Leaves 2 (SFX)"
You can send a web request, but that would be redundant since you can just use the aforementioned method. Other than these two, no.
So I’ve tried this out for a bit by changing the code a lot, but I can’t seem to make it stop “spamming” the TextLabel/output. What I mean by that is when you click the sound while another sound is playing, it “flickers”. (video attached)
Here’s the code I’ve changed so far:
local function getAudioName(id: number): string
local success, output = pcall(function()
return game:GetService("MarketplaceService"):GetProductInfo(id)
end)
if success then
if script.Parent.Parent.onoff.Text == not output.Name then
print("[ Name Already In ]")
elseif script.Parent.Parent.onoff.Text == output.Name then
script.Parent.Parent.onoff.Text = "" ..output.Name
end
print("" ..output.Name) -- returns the item's name in the marketplace
else
warn(output) -- if there was an issue, this sends it to the console so you can see what the problem is
end
-- [return ""] default name if the actual name can't be fetched
end
if sound1.Playing == true then print(getAudioName(12222019)) elseif sound1.Playing == soundplaying then print("sound already playing") end
-- and so on........
I’ve also silently removed the return " [ Teh text isnt coming!!! ] " or whatever it said, as it just kept spamming the Output no matter what.
Here’s the video from said above:
You can see in the video that in the Output, once you spam click the button, it spams the same audio in there (which is probably because of the ClickDetector on the gui and theprint("" ..output.Name)everytime you click! but im really dumb haha!)