How to make a sound loop?

This may soung like the most noobie question but i have tried this code but it just makes the sound repeatedly start
What could I use?

while wait() do
	game.Workspace["Generator sound"]:Play()
end
3 Likes

sound have a loop property

2 Likes
game.Workspace["Generator sound"].Looped = true
game.Workspace["Generator sound"]:Play()
2 Likes

When I am in studio, the code works perfectly, yet when I am in game, the code seems to not work. What could be happening?

game.Workspace["Generator sound"].Looped = true

if not game.Workspace["Generator sound"].isLoaded then
	game.Workspace["Generator sound"].Loaded:wait()
end

if not game.Workspace["Generator sound"].IsPlaying then
	game.Workspace["Generator sound"]:Play()
end

Can you tell me if this fixes it?

game.Workspace["Generator sound"].Looped = true

if not game.Workspace["Generator sound"].isLoaded then
	game.Workspace["Generator sound"].Loaded:wait()
end

game.Workspace["Generator sound"]:Play()

It did not fix it.

I updated the script. I think this will definitely fix it

2 Likes

This is a lock down approach, this should work no matter what lol

game.Workspace:WaitForChild("Generator sound").Looped = true

while not game.Workspace["Generator sound"].IsPlaying do
	game.Workspace["Generator sound"]:Play()
end

2 Likes

Definitely @Cookielnk solution is way better.

I tried it- the problem was that something was not loading and this code fixed it.