Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

3 comments

0

Sadly he can't accept your answer because of his negative reputation.

0

I'll accept that for you.

0

c :

This discussion is preserved as it was. New answers, comments, and votes are closed.