01 | local player = game.Players.LocalPlayer |
02 | local sound = player.Aviici |
03 |
04 | function Click() |
05 |
06 | player.sound.Volume = 0 |
07 |
08 | end |
09 | function Click() |
10 |
11 | player.sound.Volume = 0.25 |
12 |
13 | end |
14 |
15 |
16 | script.Parent.MouseButton 1 Down:connect(Click) |
17 | script.Parent.MouseButton 1 Down:connect(Click) |
so, i want the player make when it clicks the gui, makes the song be muted in Players > Player like here: http://prntscr.com/89kfif
At line 1-2:
1 | local player = game.Players.LocalPlayer.Aviici |
2 | local sound = player.Aviici |
You already set player
as the sound. So at line 2, the script will see if there's a other sound inside the sound on player.
In line 6 and 11, it's when the script will get confused. In scripting, you need to understand, you don't use a variable and a other variable to locate something. For example
1 | local x = script.Parent |
2 | local y = x.Parent |
3 |
4 | x.y.BrickColor = BrickColor.new( "Really black" ) -- WRONG |
5 | --/\/\ |
6 | --That CANNOT happen |
7 |
8 | y.BrickColor = BrickColor.new( "Really black" ) -- RIGHT |
So your script would be:
01 | local player = game.Players.LocalPlayer |
02 | local sound = player.Aviici |
03 |
04 | function Click() |
05 |
06 | sound.Volume = 0 |
07 |
08 | end |
09 | function Click() |
10 |
11 | sound.Volume = 0.25 |
12 |
13 | end |
14 |
15 |
16 | script.Parent.MouseButton 1 Down:connect(Click) |
17 | script.Parent.MouseButton 1 Down:connect(Click) |
IMPORTANT TIP: Use Output. It will say the errors you cause.
you have two functions with same name. and your calling them both at the same twice. just use one function and make a check to see which action to do... like so...
01 | local player = game.Players.LocalPlayer |
02 | local sound = player.PlayerGui:WaitForChild( "Aviici" ) |
03 | sound:Play() |
04 |
05 | local function Click() |
06 | if sound.Volume = = 0 then |
07 | sound.Volume = 0.25 |
08 | else |
09 | sound.Volume = 0 |
10 | end |
11 | end |
12 |
13 |
14 |
15 | script.Parent.MouseButton 1 Click:connect(Click) |