The sound is located in the PlayerGui and is named "OutdoorAmbiance," however after hours of frustrating work, I just can't get it to work, even after using the information I got from the roblox forums.
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("OutdoorAmbiance") sound.Volume = 0.3 end end)
Please at least try and explain what you fix please ;)
The problem with your script is that your "if" statement couldn't find "Humanoid" in the object that it hits. Normally, the Humanoid can be found in the character, and that's what you're (more than likely) trying to aim for.
But instead, the script is trying to find "Humanoid" in the object it hits.
For example, if "Left Leg" hits this brick, "Left Leg" will become the argument hit
. Then the script will try and find a "Humanoid" in "Left Leg". If it's nonexistent, the script will skip the "if" statement, because the condition is not satisfied.
Therefore, the audio's volume doesn't change.
local parent = script.Parent parent.Touched:connect(function(hit) if hit and hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) then local p = game.Players:GetPlayerFromCharacter(hit.Parent) -- local variable "c" is never used in this scope; refrain from making dead variables. local sound = p.PlayerGui:FindFirstChild("OutdoorAmbiance") sound.Volume = 0.3 end end)