Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- local RealPlayer = Player
- do local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end
- Player = owner
- mouse = Player:GetMouse()
- char = Player.Character
- local Turn = 0
- owner.Character.Humanoid.MaxHealth = math.huge
- owner.Character.Humanoid.Health = math.huge
- owner.Character.Humanoid.Name = "Human"
- local tweenService = game:GetService("TweenService")
- local Reloading = false
- local Ammo = 30
- local Gun = Instance.new("Part", char)
- local AimedTarget
- local Aiming = false
- local Scanning = false
- --local TBodyVelocity = Instance.new("BodyVelocity", Gun)
- Gun.Anchored = true
- Gun.CanCollide = false
- Gun.Size = Vector3.new(0.54, 1.26, 4.11)
- local Clip = Instance.new("Part", Gun)
- Clip.Size = Vector3.new(0.2,0.2,0.2)
- Clip.Position = Gun.Position + Vector3.new(0,-0.37,-0.225)
- Clip.CanCollide = false
- local weld = Instance.new("WeldConstraint")
- weld.Parent = Clip
- weld.Part0 = Clip
- weld.Part1 = Gun
- local Muzzle = Instance.new("Part", Gun)
- Muzzle.Size = Vector3.new(0.125,0.125,0.125)
- Muzzle.Position = Gun.Position + Vector3.new(0,0.05,-2.25)
- Muzzle.BrickColor = BrickColor.new(24)
- Muzzle.Reflectance = 0.1
- Muzzle.Transparency = 1
- Muzzle.CanCollide = false
- local MW = Instance.new("WeldConstraint")
- MW.Parent = Muzzle
- MW.Part0 = Muzzle
- MW.Part1 = Gun
- local CM = Instance.new("SpecialMesh", Clip)
- CM.Scale = Vector3.new(0.9,0.9,0.9)
- CM.TextureId = "http://www.roblox.com/asset/?id=116679995"
- CM.MeshId = "http://www.roblox.com/asset/?id=116740155"
- local HS = Instance.new("Sound", Gun)
- HS.SoundId = "rbxassetid://2513174484"
- local Shot = Instance.new("Sound", Gun)
- Shot.SoundId = "rbxassetid://356911785"
- local Click = Instance.new("Sound", Gun)
- Click.SoundId = "rbxassetid://132464034"
- local Error = Instance.new("Sound", Gun)
- Error.SoundId = "rbxassetid://238305078"
- local Mesh = Instance.new("SpecialMesh", Gun)
- Mesh.MeshId = "http://www.roblox.com/asset/?id=116679805"
- Mesh.TextureId = "http://www.roblox.com/asset/?id=116679995"
- Mesh.Scale = Vector3.new(0.9,0.9,0.9)
- local BBG = Instance.new("BillboardGui", Gun)
- BBG.ExtentsOffset = Vector3.new(0,2,0)
- BBG.Size = UDim2.new(4, 0, 1, 0)
- local GTB = Instance.new("TextBox", BBG)
- GTB.TextScaled = true
- GTB.TextWrapped = true
- GTB.Text = "Arcade"
- game:GetService("RunService").Stepped:Connect(function()
- if char:FindFirstChild("Head") == nil then
- script:Destroy()
- end
- --TBodyVelocity.Velocity = game.workspace.HANdsum.Head.Position - Gun.Position + Vector3.new(0, 5, 0)
- Gun.CFrame = char.Head.CFrame + Vector3.new(0,3,0)
- if Aiming ~= true then
- local x, z
- dir = CFrame.new(char.HumanoidRootPart.Position, mouse.Hit.p).lookVector
- x = dir.X
- z = dir.Z
- local cf = CFrame.new(Gun.Position, Gun.Position + Vector3.new(x, 0, z))
- Gun.CFrame = Gun.CFrame:Lerp(cf, 1)
- else
- local x, z
- local Check = game.Players:FindFirstChild(AimedTarget)
- if Check == nil then
- Scanning = false
- Aiming = false
- GTB.Text = "Mouse"
- return
- end
- local ATarget = game.workspace:FindFirstChild(AimedTarget)
- if ATarget == nil then
- Scanning = true
- return
- else
- if ATarget:FindFirstChild("Head") == nil then
- Scanning = true
- GTB.Text = "Scanning"
- else
- Scanning = false
- x = ATarget.Head.CFrame.X - Gun.CFrame.X
- z = ATarget.Head.CFrame.Z - Gun.CFrame.Z
- local cf = CFrame.new(Gun.Position, Gun.Position + Vector3.new(x, 0, z))
- Gun.CFrame = Gun.CFrame:Lerp(cf, 1)
- GTB.Text = "Target Acquired"
- end
- end
- if Scanning == true then
- local cf = Gun.CFrame * CFrame.fromEulerAnglesXYZ(0,Turn,0)
- Gun.CFrame = Gun.CFrame:Lerp(cf, 1)
- Turn = Turn + 0.2
- end
- end
- end)
- mouse.KeyDown:connect(function(key)
- if key:lower() == 'r' then
- GTB.Text = "Reloading"
- Reloading = true
- Ammo = 30
- local FakeClip = Clip:Clone()
- --Useful for getting descendants of parts
- --local descendants = FakeClip:GetDescendants()
- --for index, descendant in pairs(descendants) do
- --print(descendant.Name)
- --end
- FakeClip.Parent = game.Workspace
- FakeClip.CanCollide = false
- local Fling = Instance.new("BodyVelocity", FakeClip)
- Clip. Transparency = 1
- --FakeClip.Anchored = true
- Fling.Velocity = Vector3.new(0,0,0)
- FakeClip.WeldConstraint:Destroy()
- local RSound1 = Instance.new("Sound", Gun)
- RSound1.SoundId = "rbxassetid://132456307"
- RSound1:Play()
- wait(1.5)
- local Info = TweenInfo.new (0.3)
- local goal = {Transparency = 0}
- local Tween = tweenService:Create(Clip,Info,goal)
- Tween:Play()
- Reloading = false
- if Scanning == true then
- GTB.Text = "Scanning"
- else if Aiming ~= true then
- GTB.Text = "Mouse"
- else
- GTB.Text = "Target"
- end
- end
- wait(2)
- local RSound = Instance.new("Sound", FakeClip)
- RSound.SoundId = "rbxassetid://236382703"
- RSound:Play()
- Fling.Velocity = Vector3.new(0,200,0)
- local Info = TweenInfo.new (0.2)
- local goal = {Transparency = 1}
- local Tween = tweenService:Create(FakeClip,Info,goal)
- Tween:Play()
- wait(0.3)
- RSound1:Destroy()
- FakeClip:Destroy()
- end
- end)
- mouse.Button1Down:Connect(function()
- if Scanning == true then
- Error:Play()
- else
- if Ammo <= 0 then
- Click:Play()
- else
- if Reloading ~= true then
- Muzzle.Transparency = math.random(0.4,0.6)
- Muzzle.Orientation = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
- local Bullet = Instance.new("Part", workspace)
- Bullet.CanCollide = false
- local A1 = Instance.new("Attachment", Bullet)
- local A2 = Instance.new("Attachment", Bullet)
- A1.Position = Bullet.Position
- A2.Position = Bullet.Position + Vector3.new(0,0.05,0)
- local Trail = Instance.new("Trail", Bullet)
- Trail.Lifetime = 0.5
- Trail.Attachment0 = A1
- Trail.Attachment1 = A2
- Bullet.Size = Vector3.new(0.1,0.1,0.1)
- Bullet.Position = Muzzle.Position
- local BulletBodyPos = Instance.new("BodyVelocity", Bullet)
- Shot:Play()
- local Info = TweenInfo.new (0.3)
- local goal = {Transparency = 1}
- local Tween = tweenService:Create(Muzzle,Info,goal)
- Tween:Play()
- if Aiming ~= true then
- BulletBodyPos.Velocity = Vector3.new(mouse.Hit.p.X, mouse.Hit.p.Y, mouse.Hit.p.Z) - Bullet.Position
- local Info = TweenInfo.new (0.2)
- local goal = {Position = mouse.Hit.p}
- local Tween = tweenService:Create(Bullet,Info,goal)
- Tween:Play()
- else
- local ATarget = game.workspace:FindFirstChild(AimedTarget)
- local Info = TweenInfo.new (0.2)
- local goal = {Position = ATarget.Head.Position}
- local Tween = tweenService:Create(Bullet,Info,goal)
- Tween:Play()
- end
- --BulletBodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- Bullet.Touched:connect(function (hit)
- if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
- if hit:IsDescendantOf(char) ~= true then
- local Head = hit.Parent.Head
- if hit == Head then
- local hPlayer = hit.Parent
- hit:Destroy()
- Bullet:Destroy()
- HS:Play()
- local GroupModel = Instance.new("Model", workspace)
- for i = 10, 1, -1 do
- local blood = Instance.new("Part", GroupModel)
- blood.Size = Vector3.new(0.25,0.25,0.25)
- blood.Material = Enum.Material.Glass
- blood.BrickColor = BrickColor.new(21)
- blood.CFrame = hit.CFrame
- local bodyvel = Instance.new("BodyVelocity", blood)
- bodyvel.Velocity = Vector3.new(math.random(-3,3), -20, math.random(-3,3))
- end
- wait(1)
- local descendants = GroupModel:GetDescendants()
- for index, descendant in pairs(descendants) do
- if descendant.Name == "BodyVelocity" then
- descendant:Destroy()
- end
- end
- wait(1)
- GroupModel:Destroy()
- for index, descendant in pairs(descendants) do
- if descendant.Name == "BodyVelocity" then
- descendant:Destroy()
- end
- end
- else
- hit.Parent:FindFirstChildWhichIsA("Humanoid"):TakeDamage("20")
- Bullet:Destroy()
- end
- end
- end
- end)
- wait(2)
- Bullet:Destroy()
- Ammo = Ammo - 1
- else
- Click:Play()
- end
- end
- end
- end)
- Player.Chatted:Connect(function(message)
- if message:sub(1, 4):lower() == "aim/" then
- for index, descendant in pairs(game.workspace:GetDescendants()) do
- if descendant.Name:find(message:sub(5)) then
- AimedTarget = descendant.Name
- Aiming = true
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement