I have a TextBox that whenever the focus is lost, it takes its text, sets the SoundId of a sound object in the player named "Music" to that text, and plays the music. Here's the script:
local plr = game.Players.LocalPlayer script.Parent.FocusLost:Connect(function() local text = script.Parent.Text -- The parent is the TextBox (the radio) local music = plr.Music if text == "" then music.SoundId = "" music:Stop() script.Parent.Text = "Radio" elseif text == "audio1" then music.SoundId = 2862170886 music:Play() script.Parent.Text = "Radio" elseif text == "audio2" then music.SoundId = 169360242 music:Play() script.Parent.Text = "Radio" elseif text == "audio3" then music.SoundId = 235529455 music:Play() script.Parent.Text = "Radio" else music.SoundId = text music:Play() script.Parent.Text = "Radio" end end)
"audio1", "audio2", and "audio3" are things i built into the code so if I wanna play a favorite song i can type those instead of remembering the soundid for them.
You forgot to add the url link rbxassetid:// infront of the audio ids
local plr = game.Players.LocalPlayer script.Parent.FocusLost:Connect(function() local text = script.Parent.Text -- The parent is the TextBox (the radio) local music = plr.Music if text == "" then music.SoundId = "" music:Stop() script.Parent.Text = "Radio" elseif text == "audio1" then music.SoundId = "rbxassetid://2862170886" -- "Old Town Road" music:Play() script.Parent.Text = "Radio" elseif text == "audio2" then music.SoundId = "rbxassetid://169360242" -- "Banana Song" music:Play() script.Parent.Text = "Radio" elseif text == "audio3" then music.SoundId = "rbxassetid://235529455" -- Tomodachi Food Mart Song (fancy) music:Play() script.Parent.Text = "Radio" else music.SoundId = text music:Play() script.Parent.Text = "Radio" end end)