Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this script work?

Asked by 9 years ago
Health = {
[1]=script.Parent.Parent.Parent.Parent.Parent.MShip.MHealth,[2]=script.Parent.Parent.Parent.Parent.Parent.LShip.LHealth,[3]=script.Parent.Parent.Parent.Parent.Parent.RShip.RHealth}
Shield = {
[1]=script.Parent.Parent.Parent.Parent.Parent.MShip.MShield,[2]=script.Parent.Parent.Parent.Parent.Parent.LSHip.LShield,[3]=script.Parent.Parent.Parent.Parent.Parent.RShip.RShield}
Beam = {
[1]=script.Parent.Parent.MBeam,
[2]=script.Parent.Parent.LBeam,
[3]=script.Parent.Parent.RBeam}
Sound = {
[1]=script.Parent.Parent.MSound,
[2]=script.Parent.Parent.LSound,
[3]=script.Parent.Parent.RSound}
Effects = {
[1] = script.Parent.Parent.LEffects,
[2]=script.Parent.Parent.MEffects,
[3]=script.Parent.Parent.REffects}
FedPower = script.Parent.Parent.Parent.Parent.FedPower
Button = script.Parent.Parent.Button
debounce = false -- used only for checking if there is enough power
debounce2 = false -- used for whatever you wanted in your onclicked function

target = script.Parent.Parent.Parent.Parent.Target

function Fire(ship)
local ShieldDamage = math.random (10,20)
local HullDamage = math.random (5,10)
 Shield[ship].Value = Shield[ship].Value - ShieldDamage
 Health[ship].Value = Health[ship].Value - HullDamage
 FedPower.Value = FedPower.Value - 20
 Beam[ship].Transparency = 0.2
 Sound[ship].Firing:Play() 
 debounce2 = true
 Button.BrickColor = BrickColor.new(21)
 Effects[ship].Fire.Enabled = true
 Effects[ship].PointLight.Enabled = true
 wait(1.2)
 Beam[ship].Transparency = 1
 Effects[ship].Fire.Enabled = false
 Effects[ship].PointLight.Enabled = false
 wait(4)
 debounce2 = false
 Button.BrickColor = BrickColor.new(37)
end

FedPower.Changed:connect(function()
if FedPower.Value < 10 then
debounce = true
elseif FedPower.Value >=10 then 
debounce = false
end
end)




script.Parent.ClickDetector.MouseClick:connect(function() if not debounce and not debounce2 then Fire(target.Value) end end)

Answer this question