Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Transparency values not updating properties?

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

2 comments

0

Is this script runs only one time?

0

is that the issue? im not good with loops, so if thats what you mean, then yes.

2 answers

✓ Accepted answer

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)

4 comments

0

Yeah i totally forget .Changed. I Recommend Use This One.

0

Ty! ill try it rn

0

.Changed is deprecated, use GetPropertyChangedSignal Instead

0

wait what :eyes:

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

This discussion is preserved as it was. New answers, comments, and votes are closed.