oh sorry didn’t understand what you were trying to do with it but the playing checked with loop is a bug so you need to play them from script. how are the sounds being played or how do you know when one needs to play?
If you’ve ever played a difficulty chart obby, each difficulty has a certain music that plays as you go along. When you touch the sound region, it plays the music which is an invisible box around the difficulty. So, I’m trying to make it so if they want to mute the songs from playing, they’d press that button and essentially they’d mute all the songs from playing just incase the player has muted the music and they go onto another level they wouldn’t want the music to start playing again If that makes sense. In simpler terms, a mute button
ok so your actually playing the sounds and stoping them from a script that determines if they are in the region
so just remove the check from playing in all sounds and the for loop i added and it should work fine
I will edit the script above to reflect it
I think it was you had them all check for playing and roblox has a bug where it double plays them if checked playing and looping on start
They were already un-check marked from the the beginning and still not working.
ok so now none of them are playing right?
No like when I go to press mute, it wont mute. All the songs function properly in terms of soundregions. The main issue is me actually muting the songs, because it won’t mute them.
whats the code that plays your sounds for the regions?
local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegions")
local SoundTable = {}
for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
table.insert(SoundTable, game.Workspace.SoundRegions2[v.Name].Volume)
wait(0.2)
end
local Found = false
while wait(.5) do
for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
local sound = game.Workspace.SoundRegions2[v.Name]
Found = false
local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts) do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
print("Player Was Found")
Found = true
break
else
Found = false
print("Player Not Found")
end
end
if Found == true and sound.IsPlaying == false then
wait(0.1)
sound:Play()
for i = 0, SoundTable[i], 0.05 do
sound.Volume = i
wait(0.1)
print"Sound Faded In"
if sound.Volume == SoundTable[i] then
print("Sound Faded In")
break
end
end
end
if Found == false and sound.IsPlaying == true then
wait(0.1)
print("Waited")
for i = SoundTable[i], 0, -0.05 do
print("Fading Out")
sound.Volume = i
wait(0.1)
end
sound:Stop()
end
end
end
So if you’re in 1 region and mute it does it stay muted? Or does it unmute if you go into another region?
When I had this script, It’d do that, however I reworked the script and now we’ve ran into another issue.
so this is the problem in this script you are resetting the volume and also replaying the sound every .5 seconds if you are in that region so the other scripts settings will just be over written right away
you could fix this by using the Playback speed setting maybe checking it to see if it is 0 or 1 and if 0 don’t set sound to play and don’t change volume
for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
local sound = game.Workspace.SoundRegions2[v.Name]
if sound.PlaybackSpeed == 0 then continue end -- could change the continue to a return if you want to just run the while loop again
this should fix it if its doing what i think and you still have the other script setup the same
The reason it’s glitching is because every .5 seconds you play the sound and fade the volume back so it’s hearable. I suggest using a boolean variable true/false depending on when it’s muted and make the music fade in/out only if that variable is true.
All the songs in the folder I’ve created in the workspace are all set to Playback speed = 1.
right but in your mute script it is the only setting that this regions script doesn’t change so you can use it to detect if its muted if so don’t even check if the player is in the region because it doesn’t need to be changed
i posted the change you should try above
Which script would I put that in? Just double checking, the SoundsRegionScript right? If so, in the 0.5 second loop?
yea put it in the sounds script i left part of the main loop there so you could see it its the first for loop after your main while loop
you could put a continue above the .5 loop before it goes to sound:Play() if you wanted to do that
I put it directly in the while loop and replaced the first for loop with it, still doesn’t work. Would you want me to send you an rblx file with everything you need if that’s eaiser? Maybe there’s something I’m completely missing or something your not understanding (which is completely understandable).
local SoundRegionsWorkspace = game.Workspace:WaitForChild("SoundRegions")
local SoundTable = {}
for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
table.insert(SoundTable, game.Workspace.SoundRegions2[v.Name].Volume)
wait(0.2)
end
local Found = false
while wait(.5) do
for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
local sound = game.Workspace.SoundRegions2[v.Name]
if sound.PlaybackSpeed == 0 then continue print(sound.Name, ' Continue') end -- HERE IS THE CHANGE if you want to not check the rest of the sounds and just run while loop change continue to break
Found = false
local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
for _, part in pairs(parts) do
if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
print("Player Was Found")
Found = true
break
else
Found = false
print("Player Not Found")
end
end
if Found == true and sound.IsPlaying == false then
wait(0.1)
sound:Play()
for i = 0, SoundTable[i], 0.05 do
sound.Volume = i
wait(0.1)
print"Sound Faded In"
if sound.Volume == SoundTable[i] then
print("Sound Faded In")
break
end
end
end
if Found == false and sound.IsPlaying == true then
wait(0.1)
print("Waited")
for i = SoundTable[i], 0, -0.05 do
print("Fading Out")
sound.Volume = i
wait(0.1)
end
sound:Stop()
end
end
end
here is the script with the change in it and comments on how to change to a break if you wanted it to run the while loop again else it will just skip all below code in the script if sound is muted and go to next sound and check
That’s great! However, the mute button is still not working. I try pressing it, does nothing.
i added a print on that continue you might try it make sure its working
and does your on and off print? use prints to help you debug it they are you friend for sure just make sure to turn them off after you finish else it can cause some lag if they are printed alot