Its meant to check for Ammo, and then If it has ammo fire, if it does not then wont fire, It works until you have no ammo, then when I add More It Breaks.
wait(5)
local tool = script.Parent
local user
local tip = tool.tip
local change = tool.Handle.change
local shot = tool.Handle.shot
local wide = tool.Handle.wide
local e = tool.button1
local q = tool.button2
local Damage = math.random(15,25)
local BonusDamage = math.random(5,15)
local mode = 1
local setting = 1
local reload = false
function onKeyDown(key,g)
if key == "q" then
change:Play()
if mode == 1 then
mode = 2
g.Frame.stun.Image = "http://www.roblox.com/asset/?id=178375629"
g.Frame.kill.Image = "http://www.roblox.com/asset/?id=178375645"
elseif mode == 2 then
mode = 1
g.Frame.stun.Image = "http://www.roblox.com/asset/?id=178375645"
g.Frame.kill.Image = "http://www.roblox.com/asset/?id=178375629"
end
--print(mode)
q.BrickColor = BrickColor.new("Medium stone grey")
wait()
q.BrickColor = BrickColor.new("Dark stone grey")
elseif key == "e" then
change:Play()
if setting == 1 then
setting = 2
g.Frame.beam.Image = "http://www.roblox.com/asset/?id=178375629"
g.Frame.wide.Image = "http://www.roblox.com/asset/?id=178375645"
elseif setting == 2 then
setting = 1
g.Frame.beam.Image = "http://www.roblox.com/asset/?id=178375645"
g.Frame.wide.Image = "http://www.roblox.com/asset/?id=178375629"
end
--print(setting)
e.BrickColor = BrickColor.new("Medium stone grey")
wait()
e.BrickColor = BrickColor.new("Dark stone grey")
end
end
function Reset()
if script.Parent.Ammo.Value < 1 then reload = false
end
function impact(hit,h)
if mode == 1 then
if hit.Parent:IsA("Hat") == false and hit.Parent:IsA("Tool") == false and hit.Parent:IsA("HopperBin") == false then
h:TakeDamage(3/setting)
if hit.Parent:findFirstChild("stun") == nil then
local s = script.stun:Clone()
s.Parent = hit.Parent
s.Disabled = false
s.expose.Adornee = s.Parent.Torso
s.expose.Script.Disabled = false
h.WalkSpeed = 10
end
else
h:TakeDamage(3/setting)
if hit.Parent.Parent:findFirstChild("stun") == nil then
local s = script.stun:Clone()
s.Parent = hit.Parent.Parent
s.Disabled = false
s.expose.Adornee = s.Parent.Torso
s.expose.Script.Disabled = false
h.WalkSpeed = 10
end
end
elseif mode == 2 then
if hit.Parent:IsA("Hat") == false and hit.Parent:IsA("Tool") == false and hit.Parent:IsA("HopperBin") == false then
if hit.Parent:findFirstChild("stun") == nil then
h:TakeDamage(BonusDamage/setting)
else
h:TakeDamage(Damage/setting)
end
else
if hit.Parent.Parent:findFirstChild("stun") == nil then
h:TakeDamage(BonusDamage/setting)
else
h:TakeDamage(Damage/setting)
end
end
end
end
tool.Equipped:connect(function(mouse)
local gui = script.PhaserGui
user = tool.Parent
local g = gui:Clone()
g.Parent = game.Players:GetPlayerFromCharacter(user).PlayerGui
mouse.Button1Down:connect(function()
if user.Humanoid.Health > 1 then
if setting == 1 then
if script.Parent.Ammo.Value < 1 then reload = true Reset() return
elseif reload == false then
shot:Play()
script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
reload = true
local r = Ray.new(tip.CFrame.p, (mouse.Hit.p - tip.CFrame.p).unit*300)
local hit,position = game.Workspace:FindPartOnRay(r, user)
local h = hit and hit.Parent and hit.Parent:findFirstChild("Humanoid")
if hit ~= nil and hit.Parent.Parent:findFirstChild("Humanoid") and hit.Parent.Parent ~= workspace then
h = hit.Parent.Parent:findFirstChild("Humanoid")
end
if h then
impact(hit,h)
end
local distance = (position - tip.CFrame.p).magnitude
local rp = Instance.new("Part", workspace)
rp.Name = "RayPart"
rp.BrickColor = BrickColor.new("Bright orange")
rp.Transparency = 0
rp.Anchored = true
rp.CanCollide = false
rp.TopSurface = Enum.SurfaceType.Smooth
rp.BottomSurface = Enum.SurfaceType.Smooth
rp.formFactor = Enum.FormFactor.Custom
rp.Size = Vector3.new(0.2, 0.2, distance)
rp.CFrame = CFrame.new(position, tip.CFrame.p) * CFrame.new(0, 0, -distance/2)
local m = Instance.new("BlockMesh", rp)
m.Scale = Vector3.new(0.25,0.25,1)
local e = Instance.new("Part", workspace)
e.CFrame = CFrame.new(position)
e.Transparency = 1
e.Size = Vector3.new(1,1,1)
local f = Instance.new("Fire",e)
local pl = Instance.new("PointLight",e)
local st = rp:Clone()
st.Parent = rp
if mode == 1 then
st.BrickColor = BrickColor.new("Bright yellow")
end
st.Mesh.Scale = Vector3.new(0.5,0.5,1)
st.Transparency = 0.75
game.Debris:AddItem(rp,0.25)
game.Debris:AddItem(e,0.25)
wait(0.5)
reload = false
end
elseif setting == 2 then
if script.Parent.Ammo.Value <500 then reload = true return
elseif reload == false then
wide:Play()
script.Parent.Ammo.Value = script.Parent.Ammo.Value - 500
reload = true
for i = -130,130 do
local r = Ray.new(tip.CFrame.p, ((mouse.Hit*CFrame.new(Vector3.new((0.1*i),0,0)).p) - tip.CFrame.p).unit*100)
local hit,position = game.Workspace:FindPartOnRay(r, user)
local h = hit and hit.Parent and hit.Parent:findFirstChild("Humanoid")
if h then
impact(hit,h)
end
local distance = (position - tip.CFrame.p).magnitude
if i == 0 then
local rp = Instance.new("Part", user)
rp.Name = "RayPart"
rp.BrickColor = BrickColor.new("Bright orange")
rp.Transparency = 0
rp.Anchored = true
rp.CanCollide = false
rp.TopSurface = Enum.SurfaceType.Smooth
rp.BottomSurface = Enum.SurfaceType.Smooth
rp.formFactor = Enum.FormFactor.Custom
rp.Size = Vector3.new(0.2, 0.2, distance)
rp.CFrame = CFrame.new(position, tip.CFrame.p) * CFrame.new(0, 0, -distance/2) * CFrame.Angles(300,0,0)
local m = Instance.new("SpecialMesh", rp)
m.MeshType = "FileMesh"
m.MeshId = "http://www.roblox.com/asset/?id=1033714"
m.Scale = Vector3.new(25,1.275*distance,0.001)
local st = rp:Clone()
st.Parent = rp
st.Mesh.Scale = Vector3.new(25.5,(1.275*distance)+0.5,0.101)
st.Transparency = 0.75
if mode == 1 then
st.BrickColor = BrickColor.new("Bright yellow")
end
game.Debris:AddItem(rp,0.5)
end
end
wait(1.5)
reload = false
end
end
end
end)
mouse.KeyDown:connect(function(string) onKeyDown(string,g) end)
end)
tool.Unequipped:connect(function ()
if tool.Parent.Parent:FindFirstChild("PlayerGui") ~= nil and tool.Parent.Parent:FindFirstChild("PlayerGui"):FindFirstChild("PhaserGui") ~= nil then
tool.Parent.Parent.PlayerGui.PhaserGui:Destroy()
end
end)

1 comment
I can help you. DON'T POST A 200 LINE SCRIPT AND SAY "IT DOESNT WORK HALP MEH!"