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

Playable song gui is not working, won't register SongID, how do you make it work?

Asked by 5 years ago

Hey so I have been trying to take text from a gui, and play a song.

function music() script.Parent.Sound.SoundId = script.Parent.Frame.TextBox.Text
if script.Parent.Sound.SoundId == script.Parent.Frame.TextBox.Text then print("Apple") end script.Parent.Sound:Play() print("Working V2") if script.Parent.Sound.IsPlaying == true then print("Working V3") end end

script.Parent.Frame.TextButton.MouseButton1Click:Connect(music)

This is my script, everything prints, so I don't see the problem. The only problem I can see is in properties the sound object ID does not match the text I entered.

1 answer

Log in to vote
3
Answered by 5 years ago
Edited 5 years ago

Hi there,

This is because you are simply putting in the ID as a set of numbers. You need to write "rbxassetid://" in your script before your ID so that the song can be looked up and found. It printed everything because it still set the SoundID, but when Roblox went to find your song it couldn't find it (as you needed the rbxassetid:// bit) hence why it didn't play. If you check the output it should tell you it failed to download the song.

function music()
    script.Parent.Sound.SoundId = "rbxassetid://"..script.Parent.Frame.TextBox.Text
    if script.Parent.Sound.SoundId == script.Parent.Frame.TextBox.Text then 
        print("Apple")
    end     
    script.Parent.Sound:Play() 
    print("Working V2") 
    if script.Parent.Sound.IsPlaying == true then 
        print("Working V3") 
    end 
end

script.Parent.Frame.TextButton.MouseButton1Click:Connect(music)

PS: In future, use a Lua code block in your answer to format your code nicely.

Thanks!

0
Sorry, It's not working, I was met with this error! 07:24:36.760 - Failed to load sound rbxassetid://: Unable to download sound data ScottVulpes 105 — 5y
0
LOL DeceptiveCaster 3761 — 5y
0
Works fine for me, did you copy what I sent you? Stupid question, is your volume turned up in Roblox and on your PC? Yeah, don't insert rbxassetid:// into the TextBox. Just into the code, you only need to write the ID in the sound box with nothing else. The code will concatenate the "rbxassetid://" bit to your ID. Alvin_Blox 52 — 5y
0
Still not working. ScottVulpes 105 — 4y
Ad

Answer this question