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

I cant decrease an int value for some reason???

Asked by 4 years ago

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)

Can Someone help me please

1 answer

Log in to vote
3
Answered by 4 years ago
Edited 4 years ago

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)
0
Sadly he can't accept your answer because of his negative reputation. youtubemasterWOW 2741 — 4y
0
I'll accept that for you. Ziffixture 6913 — 4y
0
c : itz_rennox 412 — 4y
Ad

Answer this question