As you can see it writes id right, but still has argument issue:
What is the first nil about in the output?
Same results and still nothing:
its about this stroke:
text2.Text = game:GetService("MarketplaceService"):GetProductInfo(id,Enum.InfoType.Asset).Name
So the problem is, that the name doesn’t show up?
Little tip, you don’t have to create an entirely new function when using pcalls.
local marketplaceService = game:GetService('MarketplaceService')
local success, info = pcall(marketplaceService.GetProductInfo, marketplaceService, soundId, Enum.InfoType.Asset)
You could try it without the Enum.Infotype argument.
yes that’s the problem
30ch
id
isn’t being assigned a value. Try printing sound.SoundId, then printing id after :match().
Also, I’m not smart enough to understand, what :match() does.
Could anyone explain?
isn’t this how it works?
local id = Sound.SoundId:match("%d+")
Like, what does it change about the id?
I thimk this post might explain. I took it from here: How to get Sound name from Sound.SoundId? - #7 by Flubberlutsch
Yes but for whatever reason it’s returning nil which is why your function is erroring.
print(Sound.SoundId)
local id = Sound.SoundId:match("%d+")
print(id)
Also, you should switch Sound.Changed to Sound:GetPropertyChangedSignal(‘SoundId’) as .Changed is going to listen for any property which might cause it to fire prematurely.
As you can see it write id, but still has argument issue:
I think you could try it without the :match()?
I see, it’s only erroring the first time because it doesn’t have a value when .Changed is initially fired.
Add this to your function to check that the property has a value:
if not sound.SoundId then
return
end
I think it might be an empty string, not nil
, so I would check for the empty string instead. Checking both wouldn’t hurt though.
Sound.Changed:Connect(function()
if not Sound.SoundId or Sound.SoundId == "" then
return
end
-- ...
end)
It worked with it, thank you so much for helping