Music Script Broke Again

Just over a month ago, I posted a topic about how I couldn’t get my music script to work. I was making a script that would play a song when you stepped on a brick and would stop that song and play a new one when you stepped on a different brick. With some help, I got the script working perfectly. The link to the first post is below.

I returned to that script today so I could implement it into my game, only to find that it was broken. The two bricks and the script are in a separate testing game. One of the songs would not play at all in Studio when I clicked the preview button (it must have been deleted) and the other song would. Neither brick, however, would play the song it was supposed to play when I touched them in playtest.

I took the songid from the working song and put it into the actual game, and the preview wouldn’t even work there. I don’t have the slightest idea why this glitch is happening, and it’s annoying the crap out of me because I just fixed it the other week when it broke.

Pictures and script are below.

local sound = script.Parent.bruh
local partsound = workspace.Red.san
local part = script.Parent
local red = workspace.Red
local Debounce1 = false
local Debounce2 = false

    local plr = game.Players:GetPlayerFromCharacter(Object.Parent)
    if plr then
	if not Debounce1 then       
	Debounce1 = true
		red.Transparency = 0 
		part.Transparency = 1 
	Debounce2 = false

    local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
    if plr then
if not Debounce2 then  
	Debounce2 = true
		part.Transparency = 0
		red.Transparency = 1     
	Debounce1 = false

Does your script work for other sounds? Sounds (haha) like it may just be those audio ID’s that is messed up.


It works with some sounds. However, in the actual game (not the testing place) even those don’t work. I’m going to the gym rn, so I’ll continue debugging in about 2 hours.

Here’s my version of your code:

local Folder = script.Parent
local P1 = Folder:FindFirstChild("Red")
local P2 = Folder:FindFirstChild("Black")
local S1 = P1:FindFirstChildOfClass("Sound")
local S2 = P2:FindFirstChildOfClass("Sound")

local Switch = true

local function DoSwitch(Hit, P)
	local Plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
	if not Plr then return end
	if P == P1 and Switch then
		Switch = false
		P1.Transparency = 1
		P2.Transparency = 0
	elseif P == P2 and not Switch then
		Switch = true
		P1.Transparency = 0
		P2.Transparency = 1

P1.Touched:Connect(function(H) DoSwitch(H, P1) end)
P2.Touched:Connect(function(H) DoSwitch(H, P2) end)

If the sounds are incorrect then simply change:
S1 to S2
S2 to S1.

You also now need to parent the script like this:

I can’t test to see if that script works. For some reason, no matter what song I insert into my sound value, roblox won’t play it. I’ve tried about 15 songs at this point.

You probably accidentally changed a property of the Sound instance that “disabled” it, create a new instance and then try it.

Still, no songs will play. Are you aware of any setting that would mute Studio?

There is a button like this:

When it is highlighted, it means that everything is muted.

Can you hear any sounds at all coming from studios? Like footsteps when walking, etc.

This setting also affects Studios even though it may not look like it does.

Made sure both of those were set correctly - songs still will not play.

i had the same problem of songs not loading in the actual games, what worked for me was to preload the sounds before asking them to :Play(), for this i used the ContentProvider service

1 Like