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
local button = script.Parent local ExplosionOutOfBarrel = script.Parent.Parent.Partofexplode.Explosion local ExplosionSoundOutofThebarrel = script.Parent.Parent.Partofexplode.ExplosionSound local ExplodsionLight = script.Parent.Parent.Partofexplode.ExplosionLight local SmokeyBoi = script.Parent.Parent.Partofexplode.Smoke local AmountOfBombsleft = script.Parent.AmountOfBombs.Value local GuiOfBombs = game.StarterGui.ScreenGui.ShowBombs local Xplode1 = script.Parent.Parent.ExplosionPart1.Explosion1 local Xplode2 = script.Parent.Parent.ExplosionPart2.Explosion2 local PartThatOofs = script.Parent.Parent.PartThatGoesBoom local function BombGoOff() ExplosionSoundOutofThebarrel:Play() Xplode1.Visible = true PartThatOofs.Transparency = 1 PartThatOofs.CanCollide = false end script.Parent.ClickDetector.MouseClick:Connect(function() BombGoOff() AmountOfBombsleft.Value = AmountOfBombsleft.Value - 1 end)
It wont work cuz you wrote:
local AmountOfBombsleft = script.Parent.AmountOfBombs.Value
and then
AmountOfBombsleft.Value = AmountOfBombsleft.Value - 1
It wont work cuz you are trying to get the value of a value which isnt possible .-.
Change
local AmountOfBombsleft = script.Parent.AmountOfBombs.Value
to
local AmountOfBombsleft = script.Parent.AmountOfBombs
It should work now :D
local button = script.Parent local ExplosionOutOfBarrel = script.Parent.Parent.Partofexplode.Explosion local ExplosionSoundOutofThebarrel = script.Parent.Parent.Partofexplode.ExplosionSound local ExplodsionLight = script.Parent.Parent.Partofexplode.ExplosionLight local SmokeyBoi = script.Parent.Parent.Partofexplode.Smoke local AmountOfBombsleft = script.Parent.AmountOfBombs local GuiOfBombs = game.StarterGui.ScreenGui.ShowBombs local Xplode1 = script.Parent.Parent.ExplosionPart1.Explosion1 local Xplode2 = script.Parent.Parent.ExplosionPart2.Explosion2 local PartThatOofs = script.Parent.Parent.PartThatGoesBoom local function BombGoOff() ExplosionSoundOutofThebarrel:Play() Xplode1.Visible = true PartThatOofs.Transparency = 1 PartThatOofs.CanCollide = false end script.Parent.ClickDetector.MouseClick:Connect(function() BombGoOff() AmountOfBombsleft.Value = AmountOfBombsleft.Value - 1 end)