Still have questions? Join our Discord server and get real time help.
0

# [GOT IT WORKING] Is there a way to make music loop until a break in the middle?

Edited 14 days ago

Note: I solved it by stop being dumb and turning my Roblox studio volume up in my volume mixer so it's working

Hello! This might be a little picky, but I think that Roblox Lua can do this so I'm asking here before giving up.

My idea is to have it so quiet music plays in the background at .2 volume, until it abruptly stops after 5 minutes, and then starts again 2 minutes later. If you can somehow manage the impossible and make it only play to players who touch a certain brick I would be amazed and so thankful (but that might be basically impossible, so I'm not getting my hopes up)

And a small side note, the code I have doesn't work, it does the first print but goes blank after that

Here's where I got

I made a folder with the sound and the script, and the script says such:

for i =1, 1000 do --this is the repeater that repeats this entire script 1,000 times (or I wish it was)
local Music = game.Workspace.Music.Background

while Music.Volume < .2 do
wait(10)
print('Music is starting')
Music.Volume = Music.Volume + .01
wait(5)
end --I believe this should make is so that it will add .01 volume to the music until it is at .2 volume, basically making it fade in?
print("Music is at full volume!")

local Timer = 0
while Timer < 300 do
print("Seconds remaining: " .. Timer)
wait(1)
Timer = Timer + 1
if Timer == 300 then
Music:Stop()
wait(120) --this is supposed to be where the timer that stops the music in 5 minutes and then starts it back up in 2
end
end
end


This might be an overly complicated version, but it's what mess of code I could stitch together. Since the song is not exactly 5 minutes long, this is the best I could try (Unsurprisingly, it prints that the music is starting and then nothing happens).

If the fading simply does not work or Roblox has an easier way of doing that I am completely okay with the way you do it, I'm going for function over it looking like code lol