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

Sound Volume changes for LocalPlayer?

-- By Honi
Music = script.Sound -- Difines The sound you use
Music.Volume = 0


script.Parent.Touched:connect(function(hit) -- If a player hits (Part)
	Music.Volume = .5-- Plays Music
	Music.ReverbSoundEffect.DryLevel = -25
	Music.ReverbSoundEffect.WetLevel = -19
end)

script.Parent.Parent.Touched:connect(function(hit) -- If a player hits (Part)
	Music.Volume = .5 -- Plays Music
	Music.ReverbSoundEffect.DryLevel = -10
	Music.ReverbSoundEffect.WetLevel = -11
end)--Ends the script

script.Parent.Parent.Parent.Touched:connect(function(hit) -- If a player hits (Part)
	Music.Volume = 0 -- Stops Music
end)--Ends the script

After testing my script with some other guys, I then realized when on of us touches the brick the sound effects and volume changes for everyone..."Nice going Hon" xD

oof, I'm just putting this question here for now just in case I don't figure it out on my own, until then feel free to help.

btw, Every time you see the word Music in the script, its just a replacement for the sound.

4 comments

0

Remote Events.

0

Remote Events.

0

So, you want to touch a part and music will start playing?

0

thats pretty much what I was going for

1 answer

✓ Accepted answer

Hi Honoroll123, firstly, do you use a LocalScript? If yes, it is your first error because LocalScript is a script for the client and not for the Server. Secondly, use ReplicatedStorage for isolate sound to one player and not everyone. So, use ServerScript "Script", ClientScript "LocalScript" and a RemoteEvent for realised your project.

But, why use a RemoteEvent and how use it? It is a best solution for your problem and it work with FilteringEnabled.

How use? Is simple! For run the client to server use this

:FireClient(Player)

And for run the server with the Client use this

:FireServer()

Now! How insert RemoteEvent? Ever simple!

Script

local ReplicatedStorage = game:GetService('ReplicatedStorage')

local Event = ReplicatedStorage.RemoteEvent

script.Parent.Touched:Connect(function(hit)
	local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent) -- For find who is the player
	if Player then
		Event:FireClient(Player) 
	end
end)

LocalScript

local ReplicatedStorage = game:GetService('ReplicatedStorage')

local Event = ReplicatedStorage.RemoteEvent
local Sound = ReplicatedStorage.Sound

local Debounce = true

Event.OnClientEvent:Connect(function()
	if Debounce then -- Use debounce for not loop
		Debounce = false
		Sound:Play()
		Sound.Ended:wait()
		Debounce = true
	end
end)

So put LocalScript in PlayerGui or other player storage..

Sorry for my error in my text i'm a Quebecker and i speak french, so I hope this will help you and I have make this in mobile so I could not test

2 comments

0

oof, thanks gonna test now

0

I've tested out and it is working

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