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

Sound Volume changes for LocalPlayer?

Asked by
Burobuu 18
6 years ago
Edited 6 years ago
-- 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.

0
Remote Events. User#19524 175 — 6y
0
Remote Events. User#19524 175 — 6y
0
So, you want to touch a part and music will start playing? HeyItzDanniee 252 — 6y
0
thats pretty much what I was going for Burobuu 18 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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

0
oof, thanks gonna test now Burobuu 18 — 6y
0
I've tested out and it is working NiniBlackJackQc 1562 — 6y
Ad

Answer this question