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

My radio gui to play music doesn't work in a script?

Asked by 6 years ago

Hi I have a script to play some music with a GUI but it doesn't work I dont know why?

wait(8)
sound = Instance.new("Sound")
sound.Volume=1
sound.Pitch=1
sound.Name=""
sound.Looped=true
sound.PlayOnRemove=false
player = script.Parent.Parent.Parent.Parent
sound.Parent = player.Radio
Format = "http://www.roblox.com/asset/?id=##ID##"
frame = script.Parent:WaitForChild("Frame")

frame:WaitForChild("Play").MouseButton1Click:connect(function()
    local input = tonumber(frame:WaitForChild("Input").Text)
    if input then
        sound:Stop()
        sound.SoundId=Format:gsub("##ID##", tostring(input))
        sound:Play()
    end
end)
frame:WaitForChild("Stop").MouseButton1Click:connect(function()
    sound:Stop()
end)

Thanks if you can help c:

0
connect is deprecated use Connect, and do not get the player with tons of parents. Use LocalPlayer! and always use local variables User#19524 175 — 6y
0
i suspect line 17 and 10, on line 17 you should try using string.gsub instead of (string):gsub,on line 10 you should try using rbxasset:// instead of http://www.roblox.com/asset/?id= fanofpixels 718 — 6y

Answer this question