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 4 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.

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

2 answers

Log in to vote
1
Answered by 4 years ago

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)
0
Yeah i totally forget .Changed. I Recommend Use This One. DhMrfuun 1 — 4y
0
Ty! ill try it rn hihowareya115 53 — 4y
0
.Changed is deprecated, use GetPropertyChangedSignal Instead Ziffixture 6913 — 4y
0
wait what :eyes: maumaumaumaumaumua 628 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago
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

Answer this question