I’m trying to make a music volume changer gui, but the buttons are not working. The code is in a localscript and seems like it should be working. Help would be appriciated.
local part = script.Parent
part:GetPropertyChangedSignal("BrickColor"):Connect(function() -- this means you're listening for when the part's BrickColor is changed
print("My new color is: " .. part.BrickColor)
end)
It doesn’t need to be in another script, you can have multiple connections in the same script. But it does need to be outside of the mouseButtonClick connected function. What you have above looks good, you can also use Value- Changed Event.
Also make sure SoundService.RespectFilteringEnabled is set to true, if ur using a UI to change music everyone can hear.
The problem with what you have right now is that you’re changing Musicvol’s value, but so what? There isn’t any script listening for when MusicVol’s value is changed to actually change the sound’s Volume property. Like @lordmochibi suggested you can use GetPropertyChangedSignal(“Property”) to listen for whenever musicVol’s value changes and change the sound’s Volume to musicVol’s value. (If you don’t do that last part nothing would really happen.) So this would be your script:
-- Raise musicVal's value whenever script.Parent is clicked
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Sound:Play()
script.Parent.Parent.MusicVol.Value = script.Parent.Parent.MusicVol.Value + 0.1
end)
-- Change sound's volume to musicVal's value whenever musicVal's value changes
script.Parent.Parent.MusicVol:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Parent.Sound.Volume = script.Parent.Parent.MusicVol.Value
end)