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

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

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

4 comments

0

stop advertising

0

hows this advertising

0

he spammed it in chat

0

well, it was not spam but he advertised

1 answer

✓ Accepted answer

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!

2 comments

0

doesent work

0

nevermind it works now thanks

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