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

Transparency values not updating properties?

Asked by 5 years ago

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
02if 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
07end
08--Silencer on
09if 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
14end
0
Is this script runs only one time? DhMrfuun 1 — 5y
0
is that the issue? im not good with loops, so if thats what you mean, then yes. hihowareya115 53 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

You should not loop to check the transparency, use .Changed event instead

01--Silencer off
02script.Parent.Silencer.Changed:Connect(function()
03if 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
08end
09--Silencer on
10if 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
15end
16end)
0
Yeah i totally forget .Changed. I Recommend Use This One. DhMrfuun 1 — 5y
0
Ty! ill try it rn hihowareya115 53 — 5y
0
.Changed is deprecated, use GetPropertyChangedSignal Instead Ziffixture 6913 — 5y
0
wait what :eyes: maumaumaumaumaumua 628 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago
01while wait() do
02if 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
07end
08--Silencer on
09if 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
14end
15end

Try this

Answer this question