Script so far, I need it so when it dips Below X Power the clickdetector disables but when it gets above X power it re-enables
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.VFDualEffects1
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 PowerFunction()
if (FedPower.Value >=20) then
Button.ClickDetector.MaxActivationDistance = 0
if (FedPower.Value <=0) then
Button.ClickDetector.MaxActivationDistance = 10
end
end
end
function onClicked()
Damage(onClicked)
PowerFunction(onClicked)
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)
if (FedPower.Value <=0) then
Button.ClickDetector.MaxActivationDistance = 10
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
