Im making a cannon that can run out of bombs i have the amount of bombs in an int value but the value never changes when you fire
01 | local button = script.Parent |
02 | local ExplosionOutOfBarrel = script.Parent.Parent.Partofexplode.Explosion |
03 | local ExplosionSoundOutofThebarrel = script.Parent.Parent.Partofexplode.ExplosionSound |
04 | local ExplodsionLight = script.Parent.Parent.Partofexplode.ExplosionLight |
05 | local SmokeyBoi = script.Parent.Parent.Partofexplode.Smoke |
06 | local AmountOfBombsleft = script.Parent.AmountOfBombs.Value |
07 | local GuiOfBombs = game.StarterGui.ScreenGui.ShowBombs |
08 | local Xplode 1 = script.Parent.Parent.ExplosionPart 1. Explosion 1 |
09 | local Xplode 2 = script.Parent.Parent.ExplosionPart 2. Explosion 2 |
10 | local PartThatOofs = script.Parent.Parent.PartThatGoesBoom |
11 |
12 | local function BombGoOff() |
13 | ExplosionSoundOutofThebarrel:Play() |
14 | Xplode 1. Visible = true |
15 | PartThatOofs.Transparency = 1 |
It wont work cuz you wrote:
1 | local AmountOfBombsleft = script.Parent.AmountOfBombs.Value |
and then
1 | AmountOfBombsleft.Value = AmountOfBombsleft.Value - 1 |
It wont work cuz you are trying to get the value of a value which isnt possible .-.
Change
1 | local AmountOfBombsleft = script.Parent.AmountOfBombs.Value |
to
1 | local AmountOfBombsleft = script.Parent.AmountOfBombs |
It should work now :D
01 | local button = script.Parent |
02 | local ExplosionOutOfBarrel = script.Parent.Parent.Partofexplode.Explosion |
03 | local ExplosionSoundOutofThebarrel = script.Parent.Parent.Partofexplode.ExplosionSound |
04 | local ExplodsionLight = script.Parent.Parent.Partofexplode.ExplosionLight |
05 | local SmokeyBoi = script.Parent.Parent.Partofexplode.Smoke |
06 | local AmountOfBombsleft = script.Parent.AmountOfBombs |
07 | local GuiOfBombs = game.StarterGui.ScreenGui.ShowBombs |
08 | local Xplode 1 = script.Parent.Parent.ExplosionPart 1. Explosion 1 |
09 | local Xplode 2 = script.Parent.Parent.ExplosionPart 2. Explosion 2 |
10 | local PartThatOofs = script.Parent.Parent.PartThatGoesBoom |
11 |
12 | local function BombGoOff() |
13 | ExplosionSoundOutofThebarrel:Play() |
14 | Xplode 1. Visible = true |
15 | PartThatOofs.Transparency = 1 |