Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I change a TextLabel Text into a AudioName (Part2)?

So I got this down

textButton.MouseButton1Click:Connect(function()
	print("Click")
	local songs,text = results()
	local sound = DjBoard:WaitForChild("Board"):WaitForChild("Sound")
	if textBox.Text ~= ""   and textBox.Text ~= "Enter in ID"  then
		--print("enter")
		if  DjBoard:WaitForChild("Board"):WaitForChild("Sound").TimeLength == 0  and not songs  then
			print("not playing, added sound")
		local sound = DjBoard:WaitForChild("Board"):WaitForChild("Sound")
				sound.SoundId =  "rbxassetid://" .. textBox.Text
				sound:Play()
		local songName = game:GetService('MarketplaceService'):GetProductInfo( tonumber(sound) ).Name
			nowPlaying.Text = "" .. songName
		-- tonumber(sound) ).Name is line 33

But, I'm getting this

--19:26:56.487 - Argument 1 missing or nil
--19:26:56.487 - Stack Begin
--19:26:56.488 - Script 'Players.Player1.PlayerGui.ScreenGui.ClickEvents', Line 33
--19:26:56.488 - Stack End

What is the issue and what changes are supposed to be made?

3 comments

1

whats line 33?

1

tonumber(sound) is returning nil.

0

So, what changes are needed to be applied?

1 answer

✓ Accepted answer

It seems tonumber(sound) is returning nil. This is due to the fact that your 'sound' variable is an object.

You're setting the sound's SoundId by referencing textBox.Text. You can reference the same string for your GetProductInfo function.

local ms = game:GetService("MarketplaceService")
ms:GetProductInfo(tonumber(textBox.Text)).Name

1 comment

0

I'm getting a error on this particular part http://prntscr.com/ed36jl

This discussion is preserved as it was. New answers, comments, and votes are closed.