Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

LocalSound Help Please?

Asked by 9 years ago

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

1
This shouldn't be a localscript Goulstem 8144 — 9y
0
That still doesn't solve it? XxDarkMiragexX 45 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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.

0
Did everything you said, and the volume remains unchanged XxDarkMiragexX 45 — 9y
0
Test in studio, and check what the volume says. Tempestatem 884 — 9y
0
I did (server and solo testing) and the volume remains unchagned. Plus there's a huge difference between 0.05 and 0.3 volumes levels XxDarkMiragexX 45 — 9y
0
Then it isn't finding the sound. It is most likely stopping at "if sound then", so you need to find exactly where the sound is. Tempestatem 884 — 9y
Ad

Answer this question