I have a music gui that shows what song is playing and the progress on a master script, and making a mute button is apparently super difficult and I have no idea where to start, because the sound is coming out of script itself and not the “Sound”, and I had a friend who knows a lot more about scripting and tried to do everything, and they were at a loss too. Does anyone know anything that could help?
This is false. A Sound Instance does not need to be parented to a BasePart to work. If a Sound Instance is not parented to a BasePart or Attachment is is considered a global sound which plays at a fixed volume through out the whole workspace environment.
Do you have your script running in the Workspace or ServerScriptService? Since although you can add a Sound instance to a script in ServerScriptService that sound Instance won’t play any sound and has to be within the Workspace to play correctly.
This is what I have, and everytime I try to make a mute button, it’s correct but not working bc the sound is supposedly coming out of the script and not the Sound
Made this script but I removed my post:
local button = -- Button
local sound = script.Parent:WaitForChild("Sound")
button.MouseButton1Click:Connect(function()
if sound.Volume == 0 then
sound.Volume = 0.5
else
sound.Volume = 0
end
end)
Do not put that inside of the loop though. Put it before the while loop.
When I do that, It just doens’t play the sound at all and gives me an error “Players.5O50s.PlayerGui.MusicGui.MasterScript:11: attempt to index nil with ‘Connect’)”
and if i press the mute button, " Failed to load sound 0: Unable to download sound data"
Can you screenshot or possibly even screen record what’s going wrong (Show Output too)?
For the first error it looks like that MouseButton1Click
isn’t working there so check your button if it exists or check if you have called it properly.
For the second error, try and check if all of the Id’s are valid.
Is the mute button it’s own script? If so, can you remind me what was not working.
The mute button does have it’s own script, but just to change the text for “if” it mutes. The script is in the MasterScript to mute it, but mute hasn’t ever worked, what I have in the script rn just stopped the music completely.
--Variables--
local main = script.Parent:WaitForChild("Main")
local sound = script.Parent:WaitForChild("Sound")
local songs = {3534496375,2327934000,2653416959,1043783791,1591164912,1166617498,759801142,960300297,720360937,924246374,1433088556,2674683078,1273908457,886182685,1433088556,1038026083,3135449208,1311038670,4086523024,3265058713,4891671497,1988007109,4571282358,4380429016,1054877598,1566719128,1133415124,766108050,975940581,2246971189,276748653,148915250,1433399208,513662492,150386422,150384451,2631244642,2623776372} --Songs go in here (ID ONLY)
local progress = main:FindFirstChild("ProgressBar").Progress
local songName = main:FindFirstChild("SongName")
--MainScript
local button = "Mute"
local sound = script.Parent:WaitForChild("Sound")
button.MouseButton1Click:Connect(function()
if sound.Volume == 0 then
sound.Volume = 0.5
else
sound.Volume = 0
end
end)
while wait() do --repeats itself continuosly
sound:Stop() --stops the music
progress.Size = UDim2.new(0,0,1,0) --resets the song's progressbar
if not sound.IsPlaying then
local songChosen = songs[math.random(1,#songs)]--chooses a random sound
local asset = game.MarketplaceService:GetProductInfo(songChosen) -- Gets the songs id
sound.SoundId = "rbxassetid://".. songChosen
sound:Play()
songName.Text = asset.Name --changes text to the sounds name
wait(1) --prevents errors
progress:TweenSize(UDim2.new(1,0,1,0),'Out','Linear',(sound.TimeLength)-1)-- moves progess bar
wait((sound.TimeLength)-1)
end
end
So it looks like the problem here is the variable for “button”. You need to do:
local button = --Find the button
AHHHH thank u soo muchhh XD ive been trying to get this to work foreverrrr