I'm trying to make Ambiance for my game, whereas if you step outside a house, the wind sound will get louder. I have 2 bricks, one for lowering the volum and the other for increasing the volume. I already have a script to get the sound playing, however the script doesn't work. It's a local script inside the brick.
local parent = script.Parent parent.Touched:connect(function(hit) if hit and hit:findFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit) then local p = game.Players:GetPlayerFromCharacter(hit) local c = hit.Parent local sound = p:findFirstChild("OutdoorAmbient") if sound then sound.Volume = 0.3 end end end)
Please note that someone gave me this script on the forums and told be it should be local.
EDIT: The sounds are located in the player's StarterGUI
This may be wrong, but you said the sound is in the player's PlayerGui, so your script should read:
local parent = script.Parent parent.Touched:connect(function(hit) if hit and hit:findFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit) then local p = game.Players:GetPlayerFromCharacter(hit) local c = hit.Parent local sound = p.PlayerGui:findFirstChild("OutdoorAmbient")--Set it to look in the playergui if sound then sound.Volume = 0.3 end end end)
And put it in a normal script, localscripts don't work in bricks.