Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Make sure it is a local script :) --
- -- also there is no ammo limit --
- local settings = {
- ["tooltip"] = "Produced by UserOfEthanGamer"; -- Tooltip that will pop up when the mouse is hovered over the item
- ["name"] = ".56 MG"; -- Name of the gun
- ["dtime"] = .05; -- Amount of time before a bullet disappears
- ["cooldown"] = .1; -- Time between shots
- ["rldtime"] = 1; -- Reload time
- ["maxammo"] = 32; -- Amount of ammo in one magazine
- ["damage"] = 8; -- Amount of damage one bullet does
- ["automatic"] = true; -- If set to true, the gun will continously fire if the left mouse button is held down
- ["range"] = 1500; -- Maximum distance a bullet can travel in studs
- ["reloadwhenout"] = true; -- Automatically reloads the weapon if your ammo is at 0
- }
- db = false
- local rld = false
- local ammo = settings["maxammo"]
- local plr = game.Players.LocalPlayer;
- repeat wait() until plr.Character;
- local char = plr.Character;
- local mouse = plr:GetMouse()
- local tool, handle = script.Parent, script.Parent:FindFirstChild("Handle");
- local r = game:GetService("RunService")
- local hold = false
- local enabled = false
- tool.ToolTip = settings["tooltip"]
- tool.Name = settings["name"].." ".."["..ammo.."]"
- local function reload()
- if ammo <= 31 then
- if rld == false then rld = true
- if db == false then db = true
- tool.Reload:Play()
- tool.Name = "REL."
- wait(settings["rldtime"]/3)
- tool.Name = "REL.."
- wait(settings["rldtime"]/3)
- tool.Name = "REL..."
- wait(settings["rldtime"]/3)
- ammo = settings["maxammo"]
- tool.Name = settings["name"].." ".."["..ammo.."]"
- end
- end
- rld = false
- db = false
- end
- end
- local function FireRay()
- if enabled == false then return end
- if ammo > 0 then
- if db == false then db = true
- tool.Name = settings["name"].." ".."["..ammo.."]"
- tool.Shot:Play()
- ammo = ammo - 1
- local ray = Ray.new(handle.Position,(mouse.Hit.p-handle.Position).unit*settings["range"])
- local hit,pos = workspace:FindPartOnRay(ray,char)
- tool.Name = settings["name"].." ".."["..ammo.."]"
- if hit ~= nil then
- if hit.Parent:FindFirstChild("Humanoid") then
- hit.Parent.Humanoid:TakeDamage(settings["damage"])
- end
- end
- local p = Instance.new("Part",workspace)
- p.Anchored = true
- p.CanCollide = false
- p.Name = "Bullet"
- p.BrickColor = BrickColor.new("New Yeller")
- p.FormFactor = "Custom"
- p.TopSurface = "Smooth"
- p.BottomSurface = "Smooth"
- local s = (pos-handle.Position).magnitude
- p.Size = Vector3.new(.2,.2,s)
- p.CFrame = CFrame.new(pos,handle.Position)*CFrame.new(0,0,-s/2)
- coroutine.resume(coroutine.create(function()
- wait(settings["dtime"])
- p:Destroy()
- end))
- end
- end
- wait(settings["cooldown"])
- db = false
- if rld == true then db = true
- end
- end
- tool.Equipped:connect(function(mouse2)
- if enabled == false then enabled = true
- mouse2.Icon = "rbxasset://textures\\GunCursor.png"
- if settings["automatic"] == true then
- mouse.Button1Down:connect(function()
- hold = true
- while hold do
- r.RenderStepped:wait()
- FireRay()
- if ammo <= 0 and settings["reloadwhenout"] == true then
- reload()
- end
- end
- end)
- mouse.Button1Up:connect(function()
- hold = false
- end)
- else
- mouse.Button1Down:connect(function()
- FireRay()
- if ammo <= 0 and settings["reloadwhenout"] == true then
- reload()
- end
- end)
- end
- end
- tool.Unequipped:connect(function()
- if enabled == true then enabled = false
- else
- return
- end
- end)
- end)
- mouse.KeyDown:connect(function(key)
- if enabled == false then return end
- if key:lower() == "r" then
- reload()
- end
- end)
- --WARNING THIS IS A NORMAL SCRIPT--
- --DONT MIX THESE 2--
- Tool = script.Parent;
- local arms = nil
- local torso = nil
- local welds = {}
- function Equip(mouse)
- wait(0.01)
- arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
- torso = Tool.Parent:FindFirstChild("Torso")
- if arms ~= nil and torso ~= nil then
- local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
- if sh ~= nil then
- local yes = true
- if yes then
- yes = false
- sh[1].Part1 = nil
- sh[2].Part1 = nil
- local weld1 = Instance.new("Weld")
- weld1.Part0 = torso
- weld1.Parent = torso
- weld1.Part1 = arms[1]
- weld1.C1 = CFrame.new(-0.5, 0.9, 0.7) * CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
- welds[1] = weld1
- local weld2 = Instance.new("Weld")
- weld2.Part0 = torso
- weld2.Parent = torso
- weld2.Part1 = arms[2]
- weld2.C1 = CFrame.new(-1, 0.6, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-20), 0)
- welds[2] = weld2
- end
- else
- print("sh")
- end
- else
- print("arms")
- end
- end
- function Unequip(mouse)
- if arms ~= nil and torso ~= nil then
- local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
- if sh ~= nil then
- local yes = true
- if yes then
- yes = false
- sh[1].Part1 = arms[1]
- sh[2].Part1 = arms[2]
- welds[1].Parent = nil
- welds[2].Parent = nil
- end
- else
- print("sh")
- end
- else
- print("arms")
- end
- end
- Tool.Equipped:connect(Equip)
- Tool.Unequipped:connect(Unequip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement