When my music cannon fires every 4 times, the music it plays is supposed to change. However, this only works in studio and not ingame for some reason. Does anybody know an explanation as to why?
while script.Parent.Parent == game.Workspace do
math.randomseed(tick()%1*1e6)
a = math.random(1,5)
changesong = script.Parent.Part.SongNumber
script.Parent.Part.Dubstep:Resume()
script.Parent.Part.Transparency = 0.9
script.Parent.Part.Dubstep.Volume = 0.1
wait(0.1)
script.Parent.Part.Transparency = 0.8
script.Parent.Part.Dubstep.Volume = 0.2
wait(0.1)
script.Parent.Part.Transparency = 0.7
script.Parent.Part.Dubstep.Volume = 0.3
wait(0.1)
script.Parent.Part.Transparency = 0.6
wait(0.1)
script.Parent.Part.Transparency = 0.5
script.Parent.Magic.ParticleEmitter.Enabled = true
changesong.Value = (changesong.Value + 1)
wait(16)
script.Parent.Part.StopFire:Play()
script.Parent.Part.Transparency = 0.6
script.Parent.Part.Dubstep.Volume = 0.2
wait(0.1)
script.Parent.Part.Transparency = 0.7
script.Parent.Part.Dubstep.Volume = 0.1
wait(0.1)
script.Parent.Part.Transparency = 0.8
script.Parent.Part.Dubstep.Volume = 0
wait(0.1)
script.Parent.Part.Transparency = 0.9
wait(0.1)
script.Parent.Part.Transparency = 1
script.Parent.Magic.ParticleEmitter.Enabled = false
if changesong.Value % 4 == 0 then
print("The song number will be "..a)
if a == 1 then
script.Parent.Part.Dubstep.SoundId = "rbxassetid://332503821"
script.Parent.Part.Dubstep:Stop()
script.Parent.Part.Dubstep:Play()
elseif a == 2 then
script.Parent.Part.Dubstep.SoundId = "rbxassetid://244103137"
script.Parent.Part.Dubstep:Stop()
script.Parent.Part.Dubstep:Play()
elseif a == 3 then
b = math.random(1,5)
if b == 1 or 2 or 3 then
script.Parent.Part.Dubstep.SoundId = "rbxassetid://411440681"
script.Parent.Part.Dubstep:Stop()
script.Parent.Part.Dubstep:Play()
elseif b == 4 then
script.Parent.Part.Dubstep.SoundId = "rbxassetid://181486218"
script.Parent.Part.Dubstep:Stop()
script.Parent.Part.Dubstep:Play()
elseif b == 5 then
script.Parent.Part.Dubstep.SoundId = "rbxassetid://274682886"
script.Parent.Part.Dubstep:Stop()
script.Parent.Part.Dubstep:Play()
end
elseif a == 4 then
script.Parent.Part.Dubstep.SoundId = "rbxassetid://252565759"
script.Parent.Part.Dubstep:Stop()
script.Parent.Part.Dubstep:Play()
elseif a == 5 then
script.Parent.Part.Dubstep.SoundId = "rbxassetid://152811077"
script.Parent.Part.Dubstep:Stop()
script.Parent.Part.Dubstep:Play()
end
end
wait(2)
script.Parent.Part.Fire:Play()
end

2 comments
Is there an error in game? Press f9 while in a server to look at the error logs.
Ah, sorry. I forgot to check, but no, there is no error. :(