Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This script has been converted to FE by iPxter
- --https://paste2.org/C4nabzOx
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,Mouse,mouse,UserInputService,ContextActionService = owner
- do
- print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
- script.Parent = Player.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent and t.Function then
- t.Function(...)
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=Player then return end
- if io.isMouse then
- m.Target = io.Target
- m.Hit = io.Hit
- else
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local Mouse = Player:GetMouse()
- local h,t
- --Give the server mouse data 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- end]==],Player.Character)
- Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
- end
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- NumberValue1 = Instance.new("NumberValue")
- LocalScript2 = Instance.new("LocalScript")
- LocalScript3 = Instance.new("LocalScript")
- LocalScript4 = Instance.new("LocalScript")
- LocalScript5 = Instance.new("LocalScript")
- LocalScript6 = Instance.new("LocalScript")
- ScreenGui7 = Instance.new("ScreenGui")
- Frame8 = Instance.new("Frame")
- Frame9 = Instance.new("Frame")
- TextLabel10 = Instance.new("TextLabel")
- LocalScript11 = Instance.new("LocalScript")
- BoolValue12 = Instance.new("BoolValue")
- Part13 = Instance.new("Part")
- Sound14 = Instance.new("Sound")
- Sound15 = Instance.new("Sound")
- SpecialMesh16 = Instance.new("SpecialMesh")
- Tool0.Name = "Golden Smg"
- Tool0.Parent = mas
- Tool0.TextureId = "rbxassetid://168510932"
- Tool0.GripPos = Vector3.new(0, -0.200000003, 1)
- NumberValue1.Name = "Ammo"
- NumberValue1.Parent = Tool0
- LocalScript2.Name = "BackGun"
- LocalScript2.Parent = Tool0
- table.insert(cors,sandbox(LocalScript2,function()
- --made by alextomcool!!!---Edited by Sparttan.
- --to use: put in type of gun: barrel point left, barrel point right or bull-pup(main hande is in the middle of the gun)
- --step 2: put in what type of wepoan it is: assult rifle or pistol(there will be more)
- --to do list: make it easyer to modife how it weld's.
- guntype = 3--1 is assult rifle, 2 is bullpup, 3 is pistol, 4 is knife
- weldmode = 2--1 is barrel point upper-left, 2 is barrel pointing upper-right, 3 is barrel point lower-left and 4 is barrel point lower-right
- -------(note: if it is pistol or knife then 1 is on right leg, 2 is on left leg, 3 is in the back of your pants and 4 is in the front of your pants)
- model = nil--gun model, that is
- distance = 0.75--this is the distance between the part(torso/leg) and the gun. DON'T MAKE negitive
- rotation = 45--this is the turning in degrees.
- --this area is mode more for someone who's already good at gun's. please do not get mad at me if you don't understand what's under here
- y = 0--this is what's added to the current y value. positive number's make it go down. negative make's it go up
- x = 0--this is what's added to the x value(it's really the z value but it look's like the x value when on your back). positive number's make it go left. negative make's it go right
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------
- --I suggest not doing anything else under here. All you should have to change is the weldmode and guntype.
- --guntype 1 and weldmode 1 is for assault. guntype 3 and weldmode 1 is pistol position.
- --Those are what I have done so far so give me time so I can edit them into the correct position.
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------
- parts = {}
- local n = 1
- --can i have my
- function on(mouse)
- if model == nil then
- n = 1
- local m = Instance.new("Model")
- local all = script.Parent:GetChildren()
- for i = 1, #all do
- if all[i].className == "Part" then
- parts[n] = all[i].Transparency
- local brick = all[i]:clone()
- brick.Parent = m
- n = n +1
- end
- end
- wait()
- if model == nil then
- local weld = script:FindFirstChild("Weld2")
- if weld ~= nil then
- local new = weld:clone()
- new.Disabled = false
- new.Parent = m
- m.Name = script.Parent.Name
- m.Parent = script.Parent.Parent
- model = m
- local handle = model:FindFirstChild("Handle")
- if handle ~= nil then
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- if guntype == 1 then
- local torso = model.Parent:FindFirstChild("Torso")
- if torso ~= nil then
- if weldmode == 1 then--barrel pointing upper-right
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, 0.25 +y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), (math.pi / 2), 0)
- elseif weldmode == 2 then--barrel pointing upper-left
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0.25 +y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), (math.pi / 2 ) *-1, 0)
- elseif weldmode == 3 then--barrel pointing upside-right
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, -0.1+y, 0.2 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), (math.pi / 2), -1.5)
- elseif weldmode == 4 then--barrel pointing upside-left
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0.25+y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), (math.pi / 2 +rotation) *-1.1, 1)
- end
- end
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- elseif guntype == 2 then--BullPup
- local torso = model.Parent:FindFirstChild("Torso")
- if torso ~= nil then
- if weldmode == 1 then--barrel pointing upper-right
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, 0.25+y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), math.pi / 2, 0)
- elseif weldmode == 2 then--barrel pointing upper-left
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), math.pi / 2 *-1, 0)
- elseif weldmode == 3 then--barrel pointing upside-right
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), math.pi / 2, 0)
- elseif weldmode == 4 then--barrel pointing upside-left
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), math.pi / 2 *-1, 0)
- end
- end
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- elseif guntype == 3 then--pistol
- local lleg = model.Parent:FindFirstChild("Left Leg")
- local rleg = model.Parent:FindFirstChild("Right Leg")
- if lleg ~= nil and rleg ~= nil then
- if weldmode == 1 then--pistol on right leg
- local w = Instance.new("Weld")
- w.Part0 = rleg
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, 0 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
- elseif weldmode == 2 then--pistol on left leg
- local w = Instance.new("Weld")
- w.Part0 = lleg
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
- elseif weldmode == 3 then--knife in pant's back, gangsta like
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi / 2 , math.pi / 2, 0)
- elseif weldmode == 4 then--knife in pant's front, gangsta like
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi / 2 , math.pi / 2 *-1, 0)
- end
- end
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- elseif guntype == 4 then--knife
- local lleg = model.Parent:FindFirstChild("Left Leg")
- local rleg = model.Parent:FindFirstChild("Right Leg")
- local torso = model.Parent:FindFirstChild("Torso")
- if lleg ~= nil and rleg ~= nil and torso ~= nil then
- if weldmode == 1 then--pistol on right leg
- local w = Instance.new("Weld")
- w.Part0 = rleg
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, 0.15 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi, 0, 0)
- elseif weldmode == 2 then--pistol on left leg
- local w = Instance.new("Weld")
- w.Part0 = lleg
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0.15 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi, 0, 0)
- elseif weldmode == 3 then--knife in pant's back, gangsta like
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance *-1, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi , math.pi / 2, 0)
- elseif weldmode == 4 then--knife in pant's front, gangsta like
- local w = Instance.new("Weld")
- w.Part0 = torso
- w.Parent = w.Part0
- w.Part1 = handle
- w.C1 = CFrame.new(distance, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi , math.pi / 2 *-1, 0)
- end
- end
- end
- end
- end
- end
- end
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- if model ~= nil then
- n = 1
- local all = model:GetChildren()
- for i = 1, #all do
- if all[i].className == "Part" then
- all[i].Transparency = 1
- end
- end
- end
- end
- --check
- function off(mouse)
- if model ~= nil then
- n = 1
- local all = model:GetChildren()
- for i = 1, #all do
- if all[i].className == "Part" then
- all[i].Transparency = parts[n]
- local Do = true
- if Do then
- Do = false--dude!
- n = n +1
- end
- end
- end
- end
- end
- --please?
- script.Parent.Equipped:connect(on)
- script.Parent.Unequipped:connect(off)
- end))
- LocalScript3.Name = "Weld2"
- LocalScript3.Parent = LocalScript2
- LocalScript3.Disabled = true
- table.insert(cors,sandbox(LocalScript3,function()
- function Weld(x,y)
- local W = Instance.new("Weld")
- W.Part0 = x
- W.Part1 = y
- local CJ = CFrame.new(x.Position)
- local C0 = x.CFrame:inverse()*CJ
- local C1 = y.CFrame:inverse()*CJ
- W.C0 = C0
- W.C1 = C1
- W.Parent = x
- end
- function Get(A)
- if A.className == "Part" then
- Weld(script.Parent.Handle, A)
- A.Anchored = false
- else
- local C = A:GetChildren()
- for i=1, #C do
- Get(C[i])
- end
- end
- end
- local yes = true
- if yes then
- yes = false
- Get(script.Parent)
- end
- function onDied()
- script.Parent.Parent = nil
- end
- h = script.Parent.Parent:FindFirstChild("Humanoid")
- if h ~= nil then
- h.Died:connect(onDied)
- end
- end))
- LocalScript4.Name = "Crouch"
- LocalScript4.Parent = Tool0
- table.insert(cors,sandbox(LocalScript4,function()
- on = 0
- Tool = script.Parent
- welds = {}
- sh = {}
- arms = nil
- torso = nil
- f = nil
- function Crouch(ison)
- if arms == nil and torso == nil then
- arms = {Tool.Parent:FindFirstChild("Left Leg"), Tool.Parent:FindFirstChild("Right Leg")}
- torso = Tool.Parent:FindFirstChild("Torso")
- end
- if arms ~= nil and torso ~= nil then
- sh = {torso:FindFirstChild("Left Hip"), torso:FindFirstChild("Right Hip")}
- if sh ~= nil then
- local yes = true
- if yes then
- yes = false
- if ison == 1 then
- 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.75, 1)
- arms[1].Name = "LDave"
- arms[1].CanCollide = true
- welds[1] = weld1
- -------------------------------------------
- local weld2 = Instance.new("Weld")
- weld2.Part0 = torso
- weld2.Parent = torso
- weld2.Part1 = arms[2]
- weld2.C1 = CFrame.new(0.5,0.495,1.25) * CFrame.fromEulerAnglesXYZ(math.rad(90),0,0)
- arms[2].Name = "RDave"
- arms[2].CanCollide = true
- welds[2] = weld2
- ---------------------------------
- local force = Instance.new("BodyForce")
- force.Parent = torso
- f = force
- wait(0.01)
- elseif ison == 0 then
- if arms then
- sh[1].Part1 = arms[1]
- sh[2].Part1 = arms[2]
- f.Parent = nil
- arms[2].Name = "Right Leg"
- arms[1].Name = "Left Leg"
- welds[1].Parent = nil
- welds[2].Parent = nil
- end
- end
- --
- end
- else
- print("sh")
- end
- else
- print("arms")
- end
- end
- function Key(key)
- if key then
- key = string.lower(key)
- if (key=="c") then
- if on == 1 then
- on = 0
- elseif on == 0 then
- on = 1
- end
- Crouch(on)
- end
- end
- end
- function Equip(mouse)
- mouse.KeyDown:connect(Key)
- end
- script.Parent.Equipped:connect(Equip)
- end))
- LocalScript5.Name = "InstaWeld"
- LocalScript5.Parent = Tool0
- table.insert(cors,sandbox(LocalScript5,function()
- function Weld(x,y)
- local W = Instance.new("Weld")
- W.Part0 = x
- W.Part1 = y
- local CJ = CFrame.new(x.Position)
- local C0 = x.CFrame:inverse()*CJ
- local C1 = y.CFrame:inverse()*CJ
- W.C0 = C0
- W.C1 = C1
- W.Parent = x
- end
- function Get(A)
- if A.className == "Part" then
- Weld(script.Parent.Handle, A)
- A.Anchored = false
- else
- local C = A:GetChildren()
- for i=1, #C do
- Get(C[i])
- end
- end
- end
- function Finale()
- Get(script.Parent)
- end
- script.Parent.Equipped:connect(Finale)
- script.Parent.Unequipped:connect(Finale)
- Finale()
- end))
- LocalScript6.Name = "Local Gui"
- LocalScript6.Parent = Tool0
- table.insert(cors,sandbox(LocalScript6,function()
- wait(1)
- -------------------------------------Gun info
- OriginalToolName = script.Parent.Name
- ToolName="Sub_Mach"
- ClipSize=30
- ReloadTime=3
- Firerate=0
- MinSpread=.00
- MaxSpread=.5
- SpreadRate=0
- BaseDamage=8000
- automatic=true --Machingun
- burst=false --Idk!
- shot=false --Shotgun
- BarrlePos=Vector3.new(4,0.3,0)
- Cursors={"rbxasset://textures\\GunCursor.png"}
- ReloadCursor="rbxasset://textures\\GunWaitCursor.png"
- -------------------------------------
- equiped=false
- sp=script.Parent
- RayLength=3000
- Spread=0
- enabled=true
- reloading=false
- down=false
- r=game:service("RunService")
- last=0
- last2=0
- last3=0
- last4=0
- last5=0
- last6=0
- Bullet=Instance.new("Part")
- Bullet.Name="Bullet"
- Bullet.BrickColor=BrickColor.new("Medium blue")
- Bullet.Anchored=true
- Bullet.CanCollide=false
- Bullet.Locked=true
- Bullet.Size=Vector3.new(1,1,1)
- Bullet.Transparency=1
- Bullet.formFactor=0
- Bullet.TopSurface=0
- Bullet.BottomSurface=0
- mesh=Instance.new("SpecialMesh")
- mesh.Parent=Bullet
- mesh.MeshType="Brick"
- mesh.Name="Mesh"
- mesh.Scale=Vector3.new(.15,.15,1)
- sp.Name = ToolName
- MaxCharge=100000
- Charge=sp.Ammo
- cooldownTime = 0.1
- overheated = false
- overheattime = 6.1
- chargeperfireMIN = 1
- chargeperfireMAX = 2
- player=owner
- sfx=Instance.new("Sound")
- sfx.Name="HitSound"
- sfx.Pitch=2
- sfx.SoundId="http://www.roblox.com/asset/?id=15666462"
- sfx.Volume=0.7
- sfx.Looped=false
- sfx.PlayOnRemove=false
- function check()
- if equiped==true then
- if player.PlayerGui:findFirstChild("GunGui") ~= nil then
- player.PlayerGui.GunGui.Back.Frame:TweenSize(UDim2.new(Charge.Value/MaxCharge,0,1,0),"In","Linear",0.1)
- if overheated == false then
- player.PlayerGui.GunGui.Back.Status.Text = Charge.Value.."%"
- player.PlayerGui.GunGui.Back.Frame.BackgroundColor3 = Color3.new(256-0, 256-102, 256-255)
- --sp.Name=ToolName.." | "..Charge.Value.."%"
- end
- end
- sp.Ammo.Value = Charge.Value
- end
- end
- --Ugly, I hate corrotines, oh well :)
- function recharge()
- while true do
- wait(cooldownTime)
- if down==false then
- --if equiped==true then
- if overheated == false then
- if Charge.Value>0 then
- Charge.Value=Charge.Value-2--+math.random(1, 3) --not needed imo
- check()
- end
- end
- --end
- end
- end
- end
- thread=coroutine.create(recharge)
- assert(coroutine.resume(thread))
- function onChargeChanged()
- if Charge.Value >= MaxCharge then
- Charge.Value = 100
- overheated = true
- for i = 1, MaxCharge do
- wait(overheattime/MaxCharge)
- Charge.Value = Charge.Value - 1
- if player.PlayerGui:findFirstChild("GunGui") ~= nil and equiped == true then
- player.PlayerGui.GunGui.Back.Status.Text = "OVERHEATED"
- player.PlayerGui.GunGui.Back.Frame.BackgroundColor3 = Color3.new(256-255, 256-0, 256-0)
- --sp.Name=ToolName.." | "..Charge.Value.."%"
- end
- sp.Ammo.Value = Charge.Value
- check()
- if Charge.Value==0 then
- overheated = false
- if player.PlayerGui:findFirstChild("GunGui") ~= nil and equiped == true then
- player.PlayerGui.GunGui.Back.Status.Text = Charge.Value.."%"
- player.PlayerGui.GunGui.Back.Frame.BackgroundColor3 = Color3.new(256-0, 256-102, 256-255)
- --sp.Name=ToolName.." | "..Charge.Value.."%"
- end
- break
- end
- end
- overheated = false
- end
- if Charge.Value <= 0 then
- Charge.Value = 0
- if player.PlayerGui:findFirstChild("GunGui") ~= nil then
- player.PlayerGui.GunGui.Back.Status.Text = Charge.Value.."%"
- player.PlayerGui.GunGui.Back.Frame.BackgroundColor3 = Color3.new(256-0, 256-102, 256-255)
- --sp.Name=ToolName.." | "..Charge.Value.."%"
- end
- end
- end
- sp.Ammo.Changed:connect(onChargeChanged)
- function computeDirection(vec)
- local lenSquared = vec.magnitude * vec.magnitude
- local invSqrt = 1 / math.sqrt(lenSquared)
- return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
- end
- ------------------------------------------------------------------------------------Raycasting functions
- function raycast(startp, endp, ign)
- local vec=(endp-startp)
- if vec.magnitude<1000 then
- local hit,pos=game.Workspace:FindPartOnRay(Ray.new(startp,vec),ign)
- if hit and pos then
- if hit.Parent.className=="Tool" or hit.Parent.className=="Hat" then
- if hit.Parent.Parent ~= nil then
- if hit.Parent.Parent:findFirstChild("Humanoid")~=nil then
- return hit.Parent, pos
- end
- end
- elseif string.lower(hit.Name)=="glass" then
- local vec=(endp-pos)
- hit,pos=raycast(pos,vec,ign)
- elseif string.lower(hit.Name)=="water" then
- local vec=(endp-pos)
- hit,pos=raycast(pos,vec,ign)
- elseif hit.Transparency==1 or hit.Name=="Bullet" or hit.Name=="BulletTexture" then
- local vec=(endp-pos)
- hit,pos=raycast(pos,vec,hit)
- end
- end
- return hit,pos
- end
- return nil
- end
- -------------------------------------------------------------------------------
- function tagHumanoid(humanoid)
- local plr=game.Players:playerFromCharacter(sp.Parent)
- if plr~=nil then
- local tag=Instance.new("ObjectValue")
- tag.Value=plr
- tag.Name="creator"
- tag.Parent=humanoid
- delay(2,function()
- if tag~=nil then
- tag.Parent=nil
- end
- end)
- end
- end
- function onKeyDown(key,mouse)
- key=key:lower()
- --[[if key=="r" and not reloading then
- reload(mouse)
- end]]
- end
- function movecframe(p,pos)
- p.Parent=game.Lighting
- p.Position=pos
- p.Parent=game.Workspace
- end
- function checkAllyWIJ(killer, victim)
- if killer ~= victim then
- if killer.TeamColor==BrickColor.new("Bright blue") and victim.TeamColor==BrickColor.new("Bright green") then
- return true
- elseif killer.TeamColor==BrickColor.new("Bright green") and victim.TeamColor==BrickColor.new("Bright blue") then
- return true
- elseif killer.TeamColor == victim.TeamColor then
- return true
- else
- return false
- end
- return false
- else
- return true
- end
- return false
- end
- function fire(aim)
- script.Parent.Handle.Fire.Pitch=(math.random(-5,5)/10)+1
- sp.Handle.Fire:Play()
- t=r.Stepped:wait()
- last6=last5
- last5=last4
- last4=last3
- last3=last2
- last2=last
- last=t
- local bullet=Bullet:clone()
- --[[local bt2=game.Lighting.BulletTexture:clone()
- bt2.BrickColor=BrickColor.new("Bright red")
- bt2.Mesh.Scale=Vector3.new(.5,.5,2)]]--
- local totalDist=0
- Lengthdist=-RayLength/.5
- local startpoint=sp.Handle.CFrame*BarrlePos
- local direction=(aim-startpoint)
- local cfrm=CFrame.new(startpoint, direction+startpoint)
- local vector=startpoint+(direction.Unit*999)
- if (startpoint-vector).magnitude<1000 then
- if game.Workspace:FindPartOnRay(Ray.new(player.Character.Head.Position,startpoint-player.Character.Head.Position),player.Character)==nil then
- local hit,pos=raycast(startpoint,vector,player.Character)
- bullet.Parent=game.Workspace
- --bt2.Parent=game.Workspace
- if hit~=nil then
- local humanoid=hit.Parent:FindFirstChild("Humanoid")
- if humanoid~=nil then
- local damage=math.random(BaseDamage-(BaseDamage*.25),BaseDamage+(BaseDamage*.25))
- if hit.Name=="Head" then
- damage=damage*1.25
- elseif hit.Name=="Torso" then
- else
- damage=damage*.75
- end
- if humanoid.Health>0 then
- local eplr=game.Players:playerFromCharacter(humanoid.Parent)
- local plr=game.Players:playerFromCharacter(sp.Parent)
- if eplr~=nil and plr~=nil then
- if (checkAllyWIJ(plr, eplr)==false) then
- tagHumanoid(humanoid)
- humanoid.Parent:BreakJoints()
- sX=sfx:clone()
- sX.Parent=player
- sX:play()
- end
- else
- tagHumanoid(humanoid)
- humanoid:TakeDamage(damage)
- sX=sfx:clone()
- sX.Parent=player
- sX:play()
- end
- end
- end
- if (hit.Name == "Part10") or (hit.Name == "Part11") or (hit.Name == "Part21") or (hit.Name == "Part23") or (hit.Name == "Part24") or (hit.Name == "Part8") then
- rand = math.random(1,5)
- if rand == 3 then
- workspace.GlassSound:play()
- hit:breakJoints()
- end
- end
- if (hit.Parent:findFirstChild("Hit")) then
- hit.Parent.Health.Value = hit.Parent.Health.Value - BaseDamage/3
- end
- distance=(startpoint-pos).magnitude
- bullet.CFrame=cfrm*CFrame.new(0,0,-distance/2)
- bullet.Mesh.Scale=Vector3.new(.15,.15,distance)
- else
- bullet.CFrame=cfrm*CFrame.new(0,0,-RayLength/2)
- bullet.Mesh.Scale=Vector3.new(.15,.15,RayLength)
- end
- if pos~=nil then
- --bt2.CFrame=bullet.CFrame
- --movecframe(bt2,pos)
- end
- local deb=game:FindFirstChild("Debris")
- if deb==nil then
- local debris=Instance.new("Debris")
- debris.Parent=game
- end
- check()
- game.Debris:AddItem(bullet,.05)
- game.Debris:AddItem(sX, 1)
- --game.Debris:AddItem(bt2,.5)
- end
- end
- end
- function onButton1Up(mouse)
- down=false
- end
- function onButton1Down(mouse)
- h=sp.Parent:FindFirstChild("Humanoid")
- if not enabled or reloading or down or h==nil or overheated then
- return
- end
- if Charge.Value<MaxCharge and h.Health>0 then
- --[[if sp.Ammo.Value<=0 then
- if not reloading then
- reload(mouse)
- end
- return
- end]]
- down=true
- enabled=false
- while down do
- if Charge.Value>=MaxCharge or sp.Parent:FindFirstChild("Humanoid")==nil or overheated == true then
- break
- end
- if burst then
- local startpoint=sp.Handle.CFrame*BarrlePos
- local mag=(mouse.Hit.p-startpoint).magnitude
- local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag))
- fire(mouse.Hit.p+rndm)
- Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX)
- if Charge.Value>=MaxCharge then
- break
- end
- wait(.05)
- local startpoint=sp.Handle.CFrame*BarrlePos
- local mag2=((mouse.Hit.p+rndm)-startpoint).magnitude
- local rndm2=Vector3.new(math.random(-(.1/10)*mag2,(.1/10)*mag2),math.random(-(.1/10)*mag2,(.1/10)*mag2),math.random(-(.1/10)*mag2,(.1/10)*mag2))
- fire(mouse.Hit.p+rndm+rndm2)
- Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX)
- if Charge.Value>=MaxCharge then
- break
- end
- wait(.05)
- fire(mouse.Hit.p+rndm+rndm2+rndm2)
- Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX)
- elseif shot then
- Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX)
- local startpoint=sp.Handle.CFrame*BarrlePos
- local mag=(mouse.Hit.p-startpoint).magnitude
- local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag))
- fire(mouse.Hit.p+rndm)
- local mag2=((mouse.Hit.p+rndm)-startpoint).magnitude
- local rndm2=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2))
- fire(mouse.Hit.p+rndm+rndm2)
- local rndm3=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2))
- fire(mouse.Hit.p+rndm+rndm3)
- local rndm4=Vector3.new(math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2),math.random(-(.2/10)*mag2,(.2/10)*mag2))
- fire(mouse.Hit.p+rndm+rndm4)
- else
- Charge.Value=Charge.Value+math.random(chargeperfireMIN, chargeperfireMAX)
- local startpoint=sp.Handle.CFrame*BarrlePos
- local mag=(mouse.Hit.p-startpoint).magnitude
- local rndm=Vector3.new(math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag),math.random(-(Spread/10)*mag,(Spread/10)*mag))
- fire(mouse.Hit.p+rndm)
- end
- wait(Firerate)
- if not automatic then
- break
- end
- end
- enabled=true
- else
- sp.Handle.Trigger:Play()
- end
- end
- function onEquippedLocal(mouse)
- if mouse==nil then
- print("Mouse not found")
- return
- end
- script.GunGui:clone().Parent=player.PlayerGui
- mouse.Icon=Cursors[1]
- mouse.KeyDown:connect(function(key) onKeyDown(key,mouse) end)
- mouse.Button1Down:connect(function() onButton1Down(mouse) end)
- mouse.Button1Up:connect(function() onButton1Up(mouse) end)
- check()
- equiped=true
- if #Cursors>1 then
- while equiped do
- t=r.Stepped:wait()
- local action=sp.Parent:FindFirstChild("Pose")
- if action~=nil then
- if sp.Parent.Pose.Value=="Standing" then
- Spread=MinSpread
- else
- Spread=MinSpread+((4/10)*(MaxSpread-MinSpread))
- end
- else
- Spread=MinSpread
- end
- if t-last<SpreadRate then
- Spread=Spread+.1*(MaxSpread-MinSpread)
- end
- if t-last2<SpreadRate then
- Spread=Spread+.1*(MaxSpread-MinSpread)
- end
- if t-last3<SpreadRate then
- Spread=Spread+.1*(MaxSpread-MinSpread)
- end
- if t-last4<SpreadRate then
- Spread=Spread+.1*(MaxSpread-MinSpread)
- end
- if t-last5<SpreadRate then
- Spread=Spread+.1*(MaxSpread-MinSpread)
- end
- if t-last6<SpreadRate then
- Spread=Spread+.1*(MaxSpread-MinSpread)
- end
- if not reloading then
- local percent=(Spread-MinSpread)/(MaxSpread-MinSpread)
- for i=0,#Cursors-1 do
- if percent>(i/(#Cursors-1))-((1/(#Cursors-1))/2) and percent<(i/(#Cursors-1))+((1/(#Cursors-1))/2) then
- mouse.Icon=Cursors[i+1]
- end
- end
- end
- wait(Firerate*.9)
- end
- end
- end
- function onUnequippedLocal(mouse)
- if player.PlayerGui:FindFirstChild("GunGui")~=nil then
- player.PlayerGui:FindFirstChild("GunGui").Parent=nil
- end
- equiped=false
- reloading=false
- sp.Name = OriginalToolName
- end
- sp.Equipped:connect(onEquippedLocal)
- sp.Unequipped:connect(onUnequippedLocal)
- check()
- end))
- ScreenGui7.Name = "GunGui"
- ScreenGui7.Parent = LocalScript6
- Frame8.Name = "Back"
- Frame8.Parent = ScreenGui7
- Frame8.Transparency = 0.20000000298023
- Frame8.Size = UDim2.new(0, 400, 0, 25)
- Frame8.Style = Enum.FrameStyle.RobloxRound
- Frame8.Position = UDim2.new(0.5, -200, 0.75, 0)
- Frame8.Active = true
- Frame8.Visible = false
- Frame8.BackgroundColor3 = Color3.new(0, 0.4, 0.8)
- Frame8.BackgroundTransparency = 0.20000000298023
- Frame9.Parent = Frame8
- Frame9.Transparency = 0.20000000298023
- Frame9.Size = UDim2.new(0, 0, 1, 0)
- Frame9.BackgroundColor3 = Color3.new(1, 0, 0)
- Frame9.BackgroundTransparency = 0.20000000298023
- Frame9.BorderSizePixel = 0
- TextLabel10.Name = "Status"
- TextLabel10.Parent = Frame8
- TextLabel10.Transparency = 1
- TextLabel10.Size = UDim2.new(0, 100, 0.600000024, 0)
- TextLabel10.Text = "0%"
- TextLabel10.BackgroundTransparency = 1
- TextLabel10.BorderSizePixel = 0
- TextLabel10.TextColor3 = Color3.new(1, 1, 1)
- TextLabel10.TextXAlignment = Enum.TextXAlignment.Left
- LocalScript11.Name = "LocalMelee"
- LocalScript11.Parent = Tool0
- table.insert(cors,sandbox(LocalScript11,function()
- --[[
- Dax,
- See the MeleeScript.
- ]]
- local canmelee = true;
- local tool = script.Parent;
- function onKeyDown(key)
- key:lower();
- if key == "v" then
- if canmelee == false then
- return;
- end
- tool.Melee:play()
- canmelee = false;
- local rgrip = tool.Parent["Right Arm"].RightGrip;
- script.melee.Value = true;
- for i = 1,6 do
- rgrip.C1 = rgrip.C1 * CFrame.fromEulerAnglesXYZ(-0.55,0,0);
- wait();
- end
- wait(0.25);
- for i = 1, 6 do
- rgrip.C1 = rgrip.C1 * CFrame.fromEulerAnglesXYZ(0.55,0,0);
- wait();
- end
- script.melee.Value = false;
- wait(0.5);
- canmelee = true;
- end
- end
- function onSelect(mouse)
- mouse.KeyDown:connect(onKeyDown);
- end
- function blow(hit)
- local humanoid = hit.Parent:findFirstChild("Humanoid")
- if not humanoid then return end
- local vCharacter = Tool.Parent
- local vPlayer = game.Players:playerFromCharacter(vCharacter)
- local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
- if humanoid ~= hum and hum ~= nil and game.Players:playerFromCharacter(humanoid.Parent) and game.Players:playerFromCharacter(humanoid.Parent).TeamColor~=cc then
- tagHumanoid(humanoid, vPlayer)
- humanoid:TakeDamage(300)
- wait(1)
- untagHumanoid(humanoid)
- end
- end
- tool.Equipped:connect(onSelect);
- end))
- BoolValue12.Name = "melee"
- BoolValue12.Parent = LocalScript11
- Part13.Name = "Handle"
- Part13.Parent = Tool0
- Part13.Material = Enum.Material.Metal
- Part13.BrickColor = BrickColor.new("Gold")
- Part13.Rotation = Vector3.new(-180, 0, -180)
- Part13.Anchored = true
- Part13.CanCollide = false
- Part13.FormFactor = Enum.FormFactor.Custom
- Part13.Size = Vector3.new(0.283332497, 1.69999504, 3.1166575)
- Part13.CFrame = CFrame.new(-10.4149761, 0.850004494, 42.8024406, -1, 0, 0, 0, 1, 0, 0, 0, -1)
- Part13.BottomSurface = Enum.SurfaceType.Smooth
- Part13.TopSurface = Enum.SurfaceType.Smooth
- Part13.Color = Color3.new(0.937255, 0.721569, 0.219608)
- Part13.Position = Vector3.new(-10.4149761, 0.850004494, 42.8024406)
- Part13.Orientation = Vector3.new(0, 180, 0)
- Part13.Color = Color3.new(0.937255, 0.721569, 0.219608)
- Sound14.Name = "Fire"
- Sound14.Parent = Part13
- Sound14.Pitch = 1.1000000238419
- Sound14.SoundId = "rbxassetid://165946560"
- Sound14.Volume = 1
- Sound15.Name = "Reload"
- Sound15.Parent = Part13
- Sound15.SoundId = "http://www.roblox.com/asset/?id=2697432"
- Sound15.Volume = 1
- SpecialMesh16.Parent = Part13
- SpecialMesh16.MeshId = "rbxassetid://666515963"
- SpecialMesh16.Scale = Vector3.new(0.566664994, 0.566664994, 0.566664994)
- SpecialMesh16.VertexColor = Vector3.new(9, 9, 9)
- SpecialMesh16.MeshType = Enum.MeshType.FileMesh
- SpecialMesh16.Scale = Vector3.new(0.566664994, 0.566664994, 0.566664994)
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = owner.Backpack
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement