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

Adjusting a value multiple times each time you run a function?

Asked by 4 years ago

The problem So i have a gun script that adjusts a value called Ammo every time the function ToolActivated() is called the thing is that i want to subtract from that value each time i click not just the first time i clicked. Does anyone here know a way to make it so i can continue subtracting from a intvalue even after i did it once code

local tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local Ammo =  script.Parent.Values.Ammo.Value
local status = game.StarterPack.DevGun.Values:WaitForChild("Ammo")
local ShootDelay = script.Parent.Values.ShootDelay.Value
local debounce = false

function ToolActivated()
    if debounce == false then
        debounce=true


        status.Value = Ammo - 1


        wait(ShootDelay)
        debounce = false
    end
end

tool.Activated:Connect(ToolActivated)
0
more explination I basicaly need it so each time i activate the tool it subtracts 1 from the value proplayer700 25 — 4y

Answer this question