Hi! I'm just learning how to script, and I'd like some guidance. So I have a click detector and a script in a part named "button" in workspace. The script makes music play that you can hear in-game. I'm trying to script it so that when the button is pressed, the next song starts playing, and no matter how many times the button is pressed, this just repeats.
Here's the script. The song change part I scripted is at the bottom, but it doesn't really work. I'm really not sure why... I've tried scripting it other ways but I was sure this would work. Any guidance would be greatly appreciated!!
print 'Loading'
local button = script.Parent
------------------------
song1 = "http://www.roblox.com/asset/?id=2538961789" --paste wanted song ID
song2 = "http://www.roblox.com/asset/?id=4867633321"
song3 = "http://www.roblox.com/asset/?id=2231782710"
song4 = "http://www.roblox.com/asset/?id=2206587324"
-----------------------------
print 'Creating a Source of Audio'
local music = Instance.new("Sound")
music.Archivable = true
print 'Inspecting the Configurable Variables'
music.Parent = script.Parent
music.Pitch = 1
music.Volume = 3
music.Looped = false
music.Name = "Player"
print 'Loading RMP 1.0'
while (true) do
print 'Playing Sound 1'
music.SoundId = song1
music:play()
wait(130)
--2--
print 'Playing Sound 2'
music.SoundId = song2
music:play()
wait(130)
--3--
print 'Playing Sound 3'
music.SoundId = song3
music:play()
wait(130)
--4--
print 'Playing Sound 4'
music.SoundId = song4
music:play()
wait(130)
local function OnClicked()
music:Stop()
music.SoundId = song1
music:Play()
if song1.play == true then
music:Stop()
music.SoundId = song2
music:Play()
elseif song2.play == true then
music:Stop()
music.SoundId = song3
music:Play()
elseif song3.play == true then
music:Stop()
music.SoundId = song4
music:Play()
end
end
button.ClickDetector.MouseClick:connect(OnClicked)
end

1 comment
i just meant it made no sense bc it had no code block. im sure you're a great scripter, sorry!