Can anyone help me fix this script?
Health = script.Parent.Parent.Parent.Health
Shield = script.Parent.Parent.Parent.Shield
FedPower = script.Parent.Parent.Parent.FedPower
Beam = script.Parent.Parent.VFDualBeam
Beam1 = script.Parent.Parent.VFDualBeam1
Sound = script.Parent.Parent.VFDualSound
Button = script.Parent.Parent.VFDualButton
Status = script.Parent.Parent.VFDualStatus
Effects = script.Parent.Parent.VFDualEffects
Effects1 = script.Parent.Parent.VFDualEffects
debounce = false -- what it starts as, and but this up at the top with the other variables
function Damage()
if (Shield.Value <=149) then
Shield.Value = Shield.Value - 6.25
Health.Value = Health.Value - 10
elseif (Shield.Value >= 99) then
Shield.Value = Shield.Value - 6.25
Health.Value = Health.Value - 15
elseif (Shield.Value >= 49) then
Shield.Value = Shield.Value - 6.25
Health.Value = Health.Value - 20
elseif (Shield.Value >= 1) then
Shield.Value = Shield.Value - 6.25
Health.Value = Health.Value - 25
end
end
function Fire()
if debounce == false then
Damage(Fire)
FedPower.Value = FedPower.Value - 20
Beam.Transparency = 0.2
Beam1.Transparency = 0.2
Sound.Firing:Play()
Button.ClickDetector.MaxActivationDistance = 0
Status.BrickColor = BrickColor.new(21)
Effects.Fire.Enabled = true
Effects1.Fire.Enabled = true
Effects.PointLight.Enabled = true
Effects1.PointLight.Enabled = true
wait(1.2)
Beam.Transparency = 1
Beam1.Transparency = 1
Effects.Fire.Enabled = false
Effects1.Fire.Enabled = false
Effects.PointLight.Enabled = false
Effects1.PointLight.Enabled = false
wait(4)
Button.ClickDetector.MaxActivationDistance = 10
Status.BrickColor = BrickColor.new(37)
end
end
FedPower.Changed:connect(function()
if FedPower.Value <=20 then
debounce = false
elseif FedPower.Value >=20 then
debounce = true
end
end)
script.Parent.ClickDetector.MouseClick:connect(function() if not debounce then Fire() end end)