Music isn't playing?

I started working on a music script for my game, keep in mind it’s a serverside script in ServerScriptService.

The script has no errors but it doesn’t actually play the sound?

spawn(function()
	wait(5)
	while wait() do 
		local Music = ReplicatedStorage.Audio.Ambience:GetChildren();
		local RandomMusic = Music[math.random(1, #Music)]; wait();
		RandomMusic.Playing = true
		RemoteEvent:FireAllClients("Music", RandomMusic.Name);
		wait(RandomMusic.TimeLength);
	end;
end);

I have the wait() there because for some reason in Studio I die instantly as I spawn and for some reason the script gets messed up? I’m 100% sure it’s a Roblox bug.

The RemoteEvent just updates PlayerGui.

1 Like

IDK but maybe try

RandomMusic:Play()

That didn’t work. It was originally that.

There’s a post on this already. Please use the search feature before creating a new topic.

Nonetheless, here, parent the sound to Workspace:

local sound = [define sound]

local newSound = sound:Clone()
newSound.Parent = workspace
newSound:Play()
wait(newSound.TimeLength)
newSound:Destroy()

Why does it need to be parented to workspace?

ReplicatedStorage and ServerStorage are for storage, not things that are being used. Hence why you can’t move models that are in either.