So I’ve got this night vision goggle tool. it works fine when i put it in the starterpack, but when i put it into my custom gadget giver, it just starts to make the tool an automatic strobe light. So my fix was to have that local script just enable the night vision effect, while the main script turns the “enable” value off and turns the effect off. Except that doesn’t work. So I need some help. I want to either fixing this strobe light effect, or make the line of code that turns off the effect work.
LocalScript:
function check()
while wait(0.25) do
if script.Parent.Equip.Value == true then
game.Lighting.NightVision.Enabled = true
game.Lighting.GlobalShadows = false
else
game.Lighting.NightVision.Enabled = false
game.Lighting.GlobalShadows = true
end
end
end
check()
Main Script code:
cooldown = 2
name = "Night Vision"
equip = script.Parent.Equip
deb = true
sound = script.Parent.Handle.Equip
tool = script.Parent
function onActivated()
if equip.Value ~= true and deb then
deb = false
NV = Instance.new("Hat")
NV.Parent = script.Parent.Parent
NV.Name = name
script.Parent.Handle:Clone().Parent = NV
NV.AttachmentPos=Vector3.new(0,0.3,0)
script.Parent.Handle.Transparency = 1
equip.Value = true
sound:Play()
wait(cooldown)
deb = true
elseif equip.Value and deb then
deb = false
NV:Destroy()
game.Lighting.NightVision.Enabled = false
script.Parent.Handle.Transparency = 0
game.Lighting.NightVision.Enabled = false
equip.Value = false
wait(cooldown)
deb = true
end
end
script.Parent.Activated:Connect(onActivated)