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

My music script will not work what so ever?

Asked by 5 years ago

I have recently started ROBLOX Scripting, I am making a music script for my game, simple idea: It will play a sound twice then change the sound id I've tried two scripts:

01script.Parent["SONG"].Looped = true -- Keep Songs Repeating
02on = true -- do not change
03-- DO NOT EDIT --
04 
05if on == true then
06script.Parent["SONG"].SoundID = script.Parent["SOUND-1"].Value
07script.Parent["SONG"]:play()
08wait(script.Parent["Song"].TimeLength* 2)
09script.Parent["SONG"]:Pause()
10script.Parent["SONG"].SoundID = script.Parent["SOUND-2"].Value
11script.Parent["SONG"]:Play()
12wait(script.Parent["Song"].TimeLength* 2)
13script.Parent["SONG"]:Pause()
14script.Parent["SONG"].SoundID = script.Parent["SOUND-3"].Value
15script.Parent["SONG"]:Play()
View all 28 lines...

and

01local IDs = {
021236307446,
03347962424,
04344201558,
05155305277,
061456224592
07}
08local Sound = Instance.new("Sound", script.Parent)
09Sound.IsLooped = false
10Sound.Volume = 1
11while wait() do
12  for i, v in pairs(IDs) do
13    Sound.SoundId = "rbxassetid://"..v
14    Sound.Playing = true
15    wait(Sound.TimeLength * 2)
16  end
17end

neither scripts have returned any errors, what could I be doing wrong?

2 answers

Log in to vote
0
Answered by 5 years ago

Ah, you made an error with your 2nd script. "IsLooped" is not a property of audio. Try "looped" instead! :)

Here:

01local IDs = {
021236307446,
03347962424,
04344201558,
05155305277,
061456224592
07}
08local queue = 0
09local Sound = Instance.new("Sound", script.Parent)
10Sound.Volume = 1
11Sound.Looped = false
12 
13function new_song()
14    queue = queue + 1
15    if IDs[queue] == nil then
View all 22 lines...

I also recommend sticking with events and not using infinite loops to check wether or not something has changed or not.

0
Works like a charm! Thank you! develop_dreams 0 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I have already made a very innefficient music script which may or may not loop.

01print ("song1")
03 
04music:play()
05music.Ended:Wait()
06music:stop()
07 
08print ("song2")
10 
11music:play()
12music.Ended:Wait()
13music:stop()

It's pretty glitchy, but you can use some of this script if you want.

Answer this question