Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

LocalSound Help Please?

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

2 comments

1

This shouldn't be a localscript

0

That still doesn't solve it?

1 answer

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.

4 comments

0

Did everything you said, and the volume remains unchanged

0

Test in studio, and check what the volume says.

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.