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.
--Silencer off if script.Parent.Silencer.Transparency == 1 then script.Parent.Main.FlashGui.Label.Visible = true script.Parent.Handle.FireSound.Volume = 3 script.Parent.Main.FlashFX.Brightness = 13 script.Parent.Main.FlashFX.Range = 7 end --Silencer on if script.Parent.Silencer.Transparency == 0 then script.Parent.Main.FlashGui.Label.Visible = false script.Parent.Handle.FireSound.Volume = 0.1 script.Parent.Main.FlashFX.Brightness = 5 script.Parent.Main.FlashFX.Range = 3 end
You should not loop to check the transparency, use .Changed event instead
--Silencer off script.Parent.Silencer.Changed:Connect(function() if script.Parent.Silencer.Transparency == 1 then script.Parent.Main.FlashGui.Label.Visible = true script.Parent.Handle.FireSound.Volume = 3 script.Parent.Main.FlashFX.Brightness = 13 script.Parent.Main.FlashFX.Range = 7 end --Silencer on if script.Parent.Silencer.Transparency == 0 then script.Parent.Main.FlashGui.Label.Visible = false script.Parent.Handle.FireSound.Volume = 0.1 script.Parent.Main.FlashFX.Brightness = 5 script.Parent.Main.FlashFX.Range = 3 end end)
while wait() do if script.Parent.Silencer.Transparency == 1 then script.Parent.Main.FlashGui.Label.Visible = true script.Parent.Handle.FireSound.Volume = 3 script.Parent.Main.FlashFX.Brightness = 13 script.Parent.Main.FlashFX.Range = 7 end --Silencer on if script.Parent.Silencer.Transparency == 0 then script.Parent.Main.FlashGui.Label.Visible = false script.Parent.Handle.FireSound.Volume = 0.1 script.Parent.Main.FlashFX.Brightness = 5 script.Parent.Main.FlashFX.Range = 3 end end
Try this