Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
TheePBHST 154
7 years ago
Edited 7 years ago

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?

1
whats line 33? Kampfkarren 215 — 7y
1
tonumber(sound) is returning nil. Goulstem 8144 — 7y
0
So, what changes are needed to be applied? TheePBHST 154 — 7y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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
0
I'm getting a error on this particular part http://prntscr.com/ed36jl TheePBHST 154 — 7y
Ad

Answer this question