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

[CLOSED] How to stop burst weapon make ammo go into negative?

Asked by 5 years ago
Edited 5 years ago

in my FPS there is a burst fire mode but sometimes when the ammo the gets low it takes to much. For example lets say there is 2 bullets in the mag it will still take 3 and not take 2 so the ammo will be -1

Here is my script

if shooting and ammo > 0 and burst then
            for i = 1,3 do
            shoot()
            wait(60/722)
            end
            wait(.125)
            shooting = false
            end

so how would i stop this from occuring again please help me

Thanks

0
stop advertising WideSteal321 773 — 5y
0
hows this advertising Gey4Jesus69 2705 — 5y
0
he spammed it in chat WideSteal321 773 — 5y
0
well, it was not spam but he advertised WideSteal321 773 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You arent checking if the ammo has enough ammo for the burst.

if shooting and ammo > 0 and burst then
    for i = 1,3 do
        shoot()
            wait(60/722)
    end
    wait(.125)
    shooting = false
end

In the script below I check and see if there is still ammo left, if not it breaks out of the loop.

if shooting and ammo > 0 and burst then
    for i = 1,3 do
        shoot()
            wait(60/722)

        if ammo <= 0 then
            break
        end
    end
    wait(.125)
    shooting = false
end

Hope this helped!

0
doesent work fortune80 -4 — 5y
0
nevermind it works now thanks fortune80 -4 — 5y
Ad

Answer this question