Beeish

AWP Sniper.lua

Jun 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.23 KB | None | 0 0
  1. -- This script has been converted to FE by iPxter
  2.  
  3.  
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  6. do
  7. print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  8. script.Parent = Player.Character
  9.  
  10. --RemoteEvent for communicating
  11. local Event = Instance.new("RemoteEvent")
  12. Event.Name = "UserInput_Event"
  13.  
  14. --Fake event to make stuff like Mouse.KeyDown work
  15. local function fakeEvent()
  16. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  17. t.connect = t.Connect
  18. return t
  19. end
  20.  
  21. --Creating fake input objects with fake variables
  22. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  23. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  24. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  25. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  26. end}
  27. --Merged 2 functions into one by checking amount of arguments
  28. CAS.UnbindAction = CAS.BindAction
  29.  
  30. --This function will trigger the events that have been :Connect()'ed
  31. local function te(self,ev,...)
  32. local t = m[ev]
  33. if t and t._fakeEvent and t.Function then
  34. t.Function(...)
  35. end
  36. end
  37. m.TrigEvent = te
  38. UIS.TrigEvent = te
  39.  
  40. Event.OnServerEvent:Connect(function(plr,io)
  41. if plr~=Player then return end
  42. if io.isMouse then
  43. m.Target = io.Target
  44. m.Hit = io.Hit
  45. else
  46. local b = io.UserInputState == Enum.UserInputState.Begin
  47. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49. end
  50. for _,t in pairs(CAS.Actions) do
  51. for _,k in pairs(t.Keys) do
  52. if k==io.KeyCode then
  53. t.Function(t.Name,io.UserInputState,io)
  54. end
  55. end
  56. end
  57. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  58. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  59. end
  60. end)
  61. Event.Parent = NLS([==[
  62. local Player = game:GetService("Players").LocalPlayer
  63. local Event = script:WaitForChild("UserInput_Event")
  64.  
  65. local UIS = game:GetService("UserInputService")
  66. local input = function(io,a)
  67. if a then return end
  68. --Since InputObject is a client-side instance, we create and pass table instead
  69. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  70. end
  71. UIS.InputBegan:Connect(input)
  72. UIS.InputEnded:Connect(input)
  73.  
  74. local Mouse = Player:GetMouse()
  75. local h,t
  76. --Give the server mouse data 30 times every second, but only if the values changed
  77. --If player is not moving their mouse, client won't fire events
  78. while wait(1/30) do
  79. if h~=Mouse.Hit or t~=Mouse.Target then
  80. h,t=Mouse.Hit,Mouse.Target
  81. Event:FireServer({isMouse=true,Target=t,Hit=h})
  82. end
  83. end]==],Player.Character)
  84. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  85. end
  86.  
  87. -- Created by 129K
  88. local animations = {
  89. requip = {
  90. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  91. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-15)) * CFrame.new(1.5, -.5, 0);
  92. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(210), 0, math.rad(-40)) * CFrame.new(1.5, -.5, 0);
  93. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  94. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(1.5, -.5, 0);
  95. };
  96. lequip = {
  97. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  98. };
  99. runequip = {
  100. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  101. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-15)) * CFrame.new(1.5, -.5, 0);
  102. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(210), 0, math.rad(-40)) * CFrame.new(1.5, -.5, 0);
  103. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(180), 0, math.rad(-10)) * CFrame.new(1.5, -.5, 0);
  104. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(1.5, -.5, 0);
  105. CFrame.new(1.5, 0, 0);
  106. };
  107. rshoot = {
  108. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(170), 0, 0) * CFrame.new(1.5, -.5, 0);
  109. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(1.5, -.5, 0);
  110. };
  111. lshoot = {
  112. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(170), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  113. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  114. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(80)) * CFrame.new(-.5, -.35, 0);
  115. CFrame.new(0, .5, 0) * CFrame.Angles(math.rad(90), 0, math.rad(60)) * CFrame.new(-1, -.75, 0);
  116. };
  117. }
  118. local player = owner
  119. local char = player.Character
  120. local bin = Instance.new("HopperBin", player.Backpack)
  121. local barrelsize = .3
  122. local handleweld = nil
  123. local temp = true
  124. local etemp = true
  125. bin.Name = "L96A1 Magnum"
  126. function weld(part0, part1, c0, c1, parent)
  127. local w = Instance.new("Weld", parent)
  128. w.Part0 = part0
  129. w.Part1 = part1
  130. w.C0 = c0
  131. w.C1 = c1
  132. w.Name = "NewWeld"
  133. return w
  134. end
  135. function interpolateCFrame(cf1, cf2)
  136. local t1 = {cf1:components()}
  137. local t2 = {cf2:components()}
  138. local newcf = {}
  139. for i, v in pairs(t1) do
  140. local dif = t2[i] - v
  141. if i < 4 then
  142. local newValue = nil
  143. if math.abs(dif) < .1 then
  144. newValue = t2[i]
  145. else
  146. newValue = v + ((dif/math.abs(dif)) * .1)
  147. end
  148. newcf[i] = newValue
  149. else
  150. local newValue = nil
  151. if math.abs(dif) < .1 then
  152. newValue = t2[i]
  153. else
  154. newValue = v + ((dif/math.abs(dif)) * .1)
  155. end
  156. newcf[i] = newValue
  157. end
  158. end
  159. return CFrame.new(unpack(newcf))
  160. end
  161. function prop(name, sx, sy, sz, px, py, pz, anc, canc, col, par, mesh, meshtype, scalex, scaley, scalez, meshid, textureid)
  162. local part = Instance.new("Part", par)
  163. part.Name = name
  164. part.TopSurface = 0
  165. part.BottomSurface = 0
  166. part.formFactor = 3
  167. part.Size = Vector3.new(sx, sy, sz)
  168. part.Position = Vector3.new(px, py, pz)
  169. part.Anchored = anc
  170. part.CanCollide = canc
  171. part.BrickColor = BrickColor.new(col)
  172. if mesh then
  173. local m = Instance.new("SpecialMesh", part)
  174. m.MeshType = meshtype
  175. m.MeshId = meshid
  176. m.Scale = Vector3.new(scalex, scaley, scalez)
  177. m.TextureId = textureid
  178. end
  179. return part
  180. end
  181. function fade(part, speed)
  182. for i = part.Transparency, 1, speed do
  183. part.Transparency = i
  184. wait()
  185. end
  186. part:Destroy()
  187. end
  188. function clearWelds(par)
  189. for i, v in pairs(par:GetChildren()) do
  190. if v.Name == "NewWeld" and v:IsA("Weld") then
  191. v:Destroy()
  192. end
  193. end
  194. end
  195. function sound(pitch, id, par)
  196. local s = Instance.new("Sound", par)
  197. s.Pitch = pitch
  198. s.SoundId = id
  199. return s
  200. end
  201. function traceRay(pos, pos2, col, trans)
  202. local distance = (pos - pos2).magnitude
  203. local trace = Instance.new("Part", char)
  204. trace.Anchored = true
  205. trace.CanCollide = false
  206. trace.TopSurface = 0
  207. trace.BottomSurface = 0
  208. trace.formFactor = 3
  209. trace.Size = Vector3.new(.2, .2, distance)
  210. trace.BrickColor = BrickColor.new(col)
  211. trace.Transparency = trans
  212. trace.CFrame = CFrame.new(pos2, pos) * CFrame.new(0, 0, -distance/2)
  213. return trace
  214. end
  215. clearWelds(char.Torso)
  216. local back1 = prop("Part1", .1, .7, .5, 0, 0, 0, false, false, "Black", char, false)
  217. local back1weld = weld(char.Torso, back1, CFrame.new(1, -2, .6) * CFrame.Angles(math.rad(90), math.rad(20), math.rad(90)), CFrame.new(), char.Torso)
  218. local back2 = prop("Part2", .1, .2, .1, 0, 0, 0, false, false, "Grime", char, false)
  219. local back2weld = weld(back1, back2, CFrame.new(0, -.25, -.35), CFrame.new(), char.Torso)
  220. local back3 = prop("Part3", .1, .5, 1, 0, 0, 0, false, false, "Grime", char, false)
  221. local back3weld = weld(back1, back3, CFrame.new(0, .1, -.75), CFrame.new(), char.Torso)
  222. local back4 = prop("Part4", .1, .1, 1, 0, 0, 0, false, false, "Grime", char, false)
  223. local back4weld = weld(back3, back4, CFrame.new(0, .3, 0), CFrame.new(), char.Torso)
  224. local back5 = prop("Part5", .1, .1, .7, 0, 0, 0, false, false, "Grime", char, false)
  225. local back5weld = weld(back1, back5, CFrame.new(0, .4, -1.6), CFrame.new(), char.Torso)
  226. local trigger1 = prop("Part6", .1, .1, .6, 0, 0, 0, false, false, "Grime", char, false)
  227. local trigger1weld = weld(back4, trigger1, CFrame.new(0, -.6, -.4) * CFrame.Angles(-math.rad(30), 0, 0), CFrame.new(), char.Torso)
  228. local trigger2 = prop("Part7", .1, .1, .5, 0, 0, 0, false, false, "Grime", char, false)
  229. local trigger2weld = weld(back4, trigger2, CFrame.new(0, -.675, -.8) * CFrame.Angles(math.rad(15), 0, 0), CFrame.new(), char.Torso)
  230. local trigger3 = prop("Part8", .1, .1, .7, 0, 0, 0, false, false, "Grime", char, false)
  231. local trigger3weld = weld(back4, trigger3, CFrame.new(0, -.4, -.95) * CFrame.Angles(math.rad(90), 0, 0), CFrame.new(), char.Torso)
  232. local middle1 = prop("Part9", .1, .1, 1, 0, 0, 0, false, false, "Black", char, true, "Brick", .1, .0, .1, "", "") -- dis
  233. local middle1weld = weld(back5, middle1, CFrame.new(0, .05, -.8), CFrame.new(), char.Torso)
  234. local trigframe = prop("Part10", .1, .3, .3, 0, 0, 0, false, false, "Grime", char, true, "FileMesh", .3, .3, .3, "http://www.roblox.com/asset/?id=3270017", "")
  235. local trigframeweld = weld(back5, trigframe, CFrame.new(0, -.2, -.3) * CFrame.Angles(0, math.rad(90), 0), CFrame.new(), char.Torso)
  236. local middle2 = prop("Part11", .1, .3, 2, 0, 0, 0, false, false, "Grime", char, false)
  237. local middle2weld = weld(middle1, middle2, CFrame.new(0, -.1, -.4), CFrame.new(), char.Torso)
  238. local barrel = prop("Part12", .1, .1, 4, 0, 0, 0, false, false, "Black", char, true, "Brick", .5, .5, 1, "", "")
  239. local barrelweld = weld(middle1, barrel, CFrame.new(0, -.05, -2), CFrame.new(), char.Torso)
  240. local barrel2 = prop("Part13", barrelsize, 2, barrelsize, 0, 0, 0, false, false, "Black", char, false) Instance.new("CylinderMesh", barrel2)
  241. local barrel2weld = weld(barrel, barrel2, CFrame.new(0, 0, -2.5) * CFrame.Angles(math.rad(90), 0, 0), CFrame.new(), char.Torso)
  242. local scope1 = prop("Part14", .1, .2, .1, 0, 0, 0, false, false, "Black", char, true, "Brick", .5, .5, .5, "", "")
  243. local scope1weld = weld(middle1, scope1, CFrame.new(0, .1, .25), CFrame.new(), char.Torso)
  244. local scope2 = prop("Part14", .1, .2, .1, 0, 0, 0, false, false, "Black", char, true, "Brick", .5, .5, .5, "", "")
  245. local scope2weld = weld(middle1, scope2, CFrame.new(0, .1, -.25), CFrame.new(), char.Torso)
  246. local scope3 = prop("Part15", .1, 1.5, .1, 0, 0, 0, false, false, "Black", char, false) Instance.new("CylinderMesh", scope3)
  247. local scope3weld = weld(middle1, scope3, CFrame.new(0, .2, 0) * CFrame.Angles(math.rad(90), 0, 0), CFrame.new(), char.Torso)
  248. local scope4 = prop("Part16", .2, .3, .2, 0, 0, 0, false, false, "Black", char, true, "FileMesh", .2, .3, .2, "http://www.roblox.com/asset/?id=1033714", "")
  249. local scope4weld = weld(middle1, scope4, CFrame.new(0, .2, .7) * CFrame.Angles(math.rad(270), 0, 0), CFrame.new(), char.Torso)
  250. local scope5 = prop("Part17", .3, .35, .3, 0, 0, 0, false, false, "Black", char, true, "FileMesh", .3, .35, .3, "http://www.roblox.com/asset/?id=1033714", "")
  251. local scope5weld = weld(middle1, scope5, CFrame.new(0, .2, -.7) * CFrame.Angles(math.rad(-270), 0, 0), CFrame.new(), char.Torso)
  252. local rarmweld = weld(char.Torso, nil, CFrame.new(1.5, 0, 0), CFrame.new(), char.Torso)
  253. local larmweld = weld(char.Torso, nil, CFrame.new(-1.5, 0, 0), CFrame.new(), char.Torso)
  254. local gyro = Instance.new("BodyGyro", char.Torso)
  255. gyro.P = 10000
  256. gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  257. pmouse.Move:connect(function()
  258. gyro.cframe = CFrame.new(char.Torso.Position, Vector3.new(pmouse.Hit.p.X, char.Torso.Position.Y, pmouse.Hit.p.Z))
  259. end)
  260. function onEquip(mouse)
  261. repeat wait() until etemp and temp
  262. etemp = false
  263. rarmweld.Part1 = char["Right Arm"]
  264. local frame = 1
  265. coroutine.wrap(function()
  266. while rarmweld and animations.requip[frame] do
  267. rarmweld.C0 = interpolateCFrame(rarmweld.C0, animations.requip[frame])
  268. if rarmweld.C0 == animations.requip[frame] then
  269. frame = frame + 1
  270. else
  271. wait()
  272. end
  273. end
  274. end)()
  275. repeat wait() until frame == 3
  276. back1weld.Part0 = nil
  277. handleweld = weld(char["Right Arm"], back1, CFrame.new(-.5, 1, -.3) * CFrame.Angles(math.rad(270), 0, 0), CFrame.new(), char.Torso)
  278. repeat wait() until frame == 5
  279. larmweld.Part1 = char["Left Arm"]
  280. local frame2 = 1
  281. coroutine.wrap(function()
  282. while larmweld and animations.lequip[frame2] do
  283. larmweld.C0 = interpolateCFrame(larmweld.C0, animations.lequip[frame2])
  284. if larmweld.C0 == animations.lequip[frame2] then
  285. frame2 = frame2 + 1
  286. else
  287. wait()
  288. end
  289. end
  290. etemp = true
  291. end)()
  292. repeat wait() until frame == 6
  293. mouse.Button1Down:connect(function()
  294. if not temp then return end
  295. temp = false
  296. local frame3 = 1
  297. coroutine.wrap(function()
  298. while rarmweld and animations.rshoot[frame3] do
  299. rarmweld.C0 = interpolateCFrame(rarmweld.C0, animations.rshoot[frame3])
  300. if rarmweld.C0 == animations.rshoot[frame3] then
  301. frame3 = frame3 + 1
  302. else
  303. wait()
  304. end
  305. end
  306. end)()
  307. local frame4 = 1
  308. coroutine.wrap(function()
  309. while larmweld and animations.lshoot[frame4] do
  310. larmweld.C0 = interpolateCFrame(larmweld.C0, animations.lshoot[frame4])
  311. if larmweld.C0 == animations.lshoot[frame4] then
  312. frame4 = frame4 + 1
  313. else
  314. wait()
  315. end
  316. end
  317. wait(.1)
  318. temp = true
  319. end)()
  320. local ray = Ray.new(barrel2.Position, (mouse.Hit.p - barrel2.Position).unit * 500)
  321. sound(2, "http://www.roblox.com/Asset/?id=16211041", barrel2):play()
  322. local hit, pos = workspace:FindPartOnRay(ray, char)
  323. if hit and hit.Parent:FindFirstChild("Humanoid") then
  324. local dmg = math.random(70, 100)
  325. if hit.Name ~= "Head" then
  326. hit.Parent.Humanoid:TakeDamage(dmg)
  327. hit.Parent.Humanoid.Sit = true
  328. else
  329. hit.Parent:BreakJoints()
  330. sound(1, "http://www.roblox.com/asset/?id=1876552", workspace):play()
  331. end
  332. if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) == nil then return end
  333. local bl = Instance.new("Part", workspace)
  334. bl.Name = "Blood"
  335. bl.BrickColor = BrickColor.new("Really red")
  336. bl.FormFactor = 3
  337. bl.TopSurface = 0
  338. bl.BottomSurface = 0
  339. bl.Size = Vector3.new(1, .1, 1)
  340. bl.Position = hit.Parent.Head.Position + Vector3.new(0, 3, 0)
  341. local bbg = Instance.new("BillboardGui", bl)
  342. bbg.Adornee = bl
  343. bbg.Size = UDim2.new(1, 0, 1, 0)
  344. bbg.StudsOffset = Vector3.new(0, 1, 0)
  345. local txt = Instance.new("TextLabel", bbg)
  346. txt.Position = UDim2.new(0.5, 0, 0.5, 0)
  347. txt.FontSize = "Size14"
  348. txt.TextColor3 = Color3.new(1, 1, 1)
  349. txt.Text = hit.Name ~= "Head" and dmg or "HEADSHOT"
  350. coroutine.wrap(fade)(bl, 0.005)
  351. end
  352. if hit and hit.Parent:IsA("Hat") then
  353. hit:BreakJoints()
  354. end
  355. Spawn(function()
  356. local tr = traceRay(barrel2.Position, pos, "White", .5)
  357. fade(tr, .01)
  358. end)
  359. repeat wait() until frame4 == 3
  360. sound(1, "http://roblox.com/asset/?id=10209881", middle2):play()
  361. end)
  362. end
  363. function onUnequip()
  364. repeat wait() until etemp and temp
  365. etemp = false
  366. local frame = 1
  367. coroutine.wrap(function()
  368. while rarmweld and animations.runequip[frame] do
  369. rarmweld.C0 = interpolateCFrame(rarmweld.C0, animations.runequip[frame])
  370. if rarmweld.C0 == animations.runequip[frame] then
  371. frame = frame + 1
  372. else
  373. wait()
  374. end
  375. end
  376. etemp = true
  377. end)()
  378. coroutine.wrap(function()
  379. while larmweld do
  380. larmweld.C0 = interpolateCFrame(larmweld.C0, CFrame.new(-1.5, 0, 0))
  381. if larmweld.C0 == CFrame.new(-1.5, 0, 0) then
  382. break
  383. else
  384. wait()
  385. end
  386. end
  387. end)()
  388. repeat wait() until frame == 4
  389. handleweld:Remove()
  390. back1weld:Remove()
  391. back1weld = weld(char.Torso, back1, CFrame.new(1, -2, .6) * CFrame.Angles(math.rad(90), math.rad(20), math.rad(90)), CFrame.new(), char.Torso)
  392. repeat wait() until frame == 7
  393. rarmweld.Part1 = nil
  394. larmweld.Part1 = nil
  395. end
  396. bin.Selected:connect(onEquip)
  397. bin.Deselected:connect(onUnequip)
Add Comment
Please, Sign In to add comment