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.
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!