Argument 1 missing or nil while trying to get Sound name

As you can see it writes id right, but still has argument issue:

image

What is the first nil about in the output?

2 Likes

Same results and still nothing:

image

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?

1 Like

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)
1 Like

You could try it without the Enum.Infotype argument.

1 Like

yes that’s the problem

30ch

1 Like

id isn’t being assigned a value. Try printing sound.SoundId, then printing id after :match().

1 Like

image

Also, I’m not smart enough to understand, what :match() does.

Could anyone explain?

1 Like

isn’t this how it works?

local id = Sound.SoundId:match("%d+")

Like, what does it change about the id?

1 Like

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.

2 Likes

As you can see it write id, but still has argument issue:
image

I think you could try it without the :match()?

1 Like

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
2 Likes

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)
2 Likes

It worked with it, thank you so much for helping

2 Likes