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

The else statement wont run?

Asked by 4 years ago
01local Damage = game.ReplicatedStorage.Guns.Colt.Damage.Value
02local Ammo = game.ReplicatedStorage.Guns.Colt.Ammo.Value
03local MaxAmmo = game.ReplicatedStorage.Guns.Colt.MaxAmmo.Value
04local AmmoReloadTime = game.ReplicatedStorage.Guns.Colt.ReloadTime.Value
05 
06local Player = game.Players.LocalPlayer
07local Mouse = Player:GetMouse()
08 
09local Handle = script.Parent.Handle
10local Colt = script.Parent
11 
12script.Parent.Activated:Connect(function()
13print("activated")
14    if Ammo ~= 0 then
15        print('enough ammo')
View all 28 lines...

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

Log in to vote
0
Answered by 4 years ago

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

0
ellxiac, i already tried that before, it doesn't work. InspireWithFun 9 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question