The title explains it all. I'm trying to make it so when the silencer of the gun is off, it changes the sound and the effects. The silencer on part works properly, but the silencer off part doesn't update the properties.
01 | --Silencer off |
02 | if script.Parent.Silencer.Transparency = = 1 then |
03 | script.Parent.Main.FlashGui.Label.Visible = true |
04 | script.Parent.Handle.FireSound.Volume = 3 |
05 | script.Parent.Main.FlashFX.Brightness = 13 |
06 | script.Parent.Main.FlashFX.Range = 7 |
07 | end |
08 | --Silencer on |
09 | if script.Parent.Silencer.Transparency = = 0 then |
10 | script.Parent.Main.FlashGui.Label.Visible = false |
11 | script.Parent.Handle.FireSound.Volume = 0.1 |
12 | script.Parent.Main.FlashFX.Brightness = 5 |
13 | script.Parent.Main.FlashFX.Range = 3 |
14 | end |
You should not loop to check the transparency, use .Changed event instead
01 | --Silencer off |
02 | script.Parent.Silencer.Changed:Connect( function () |
03 | if script.Parent.Silencer.Transparency = = 1 then |
04 | script.Parent.Main.FlashGui.Label.Visible = true |
05 | script.Parent.Handle.FireSound.Volume = 3 |
06 | script.Parent.Main.FlashFX.Brightness = 13 |
07 | script.Parent.Main.FlashFX.Range = 7 |
08 | end |
09 | --Silencer on |
10 | if script.Parent.Silencer.Transparency = = 0 then |
11 | script.Parent.Main.FlashGui.Label.Visible = false |
12 | script.Parent.Handle.FireSound.Volume = 0.1 |
13 | script.Parent.Main.FlashFX.Brightness = 5 |
14 | script.Parent.Main.FlashFX.Range = 3 |
15 | end |
16 | end ) |
01 | while wait() do |
02 | if script.Parent.Silencer.Transparency = = 1 then |
03 | script.Parent.Main.FlashGui.Label.Visible = true |
04 | script.Parent.Handle.FireSound.Volume = 3 |
05 | script.Parent.Main.FlashFX.Brightness = 13 |
06 | script.Parent.Main.FlashFX.Range = 7 |
07 | end |
08 | --Silencer on |
09 | if script.Parent.Silencer.Transparency = = 0 then |
10 | script.Parent.Main.FlashGui.Label.Visible = false |
11 | script.Parent.Handle.FireSound.Volume = 0.1 |
12 | script.Parent.Main.FlashFX.Brightness = 5 |
13 | script.Parent.Main.FlashFX.Range = 3 |
14 | end |
15 | end |
Try this