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

The else statement wont run?

local Damage = game.ReplicatedStorage.Guns.Colt.Damage.Value
local Ammo = game.ReplicatedStorage.Guns.Colt.Ammo.Value
local MaxAmmo = game.ReplicatedStorage.Guns.Colt.MaxAmmo.Value
local AmmoReloadTime = game.ReplicatedStorage.Guns.Colt.ReloadTime.Value

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local Handle = script.Parent.Handle
local Colt = script.Parent

script.Parent.Activated:Connect(function()
print("activated")
	if Ammo ~= 0 then
		print('enough ammo')
		game.ReplicatedStorage.Guns.Colt.Ammo.Value = game.ReplicatedStorage.Guns.Colt.Ammo.Value - 1 
		print('removed ammo')
		if Mouse.Target~= nil then
			if Mouse.Target.Parent:FindFirstChild('Humanoid') then
				print('targetted player')
				game.ReplicatedStorage.Guns.Fire:FireServer(Damage, Ammo, MaxAmmo, Mouse, Mouse.Target, AmmoReloadTime)
			end	
		end	
	else
		print('no ammo')
		
	end	
end)

iin the else statement, it never prints or does what i put in the else statement. the ammo number goes to negative and still damages players what do i do to make it stop when the ammo is = 0

2 answers

✓ Accepted answer

You should check if the player has more than 0 ammo, so you would need to use ">" instead of "~=" in line 14.

1 comment

0

ellxiac, i already tried that before, it doesn't work.

It has been fixed, i just needed to remove the .Value from the variable and put it in the if statement line

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