Advertisement
Createok

Air Strike

Dec 6th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.13 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. if script == nil then return end
  88.  
  89.  
  90. Player = game:GetService("Players"):FindFirstChild("ic3w0lf589")
  91. Name = "Artillery Beacon"
  92. selected = false
  93. Button1Down = false
  94. thrown = false
  95.  
  96.  
  97. function makeParts(format)
  98. local beacon = Instance.new("Model")
  99. beacon.Name = Name
  100. beacon.Parent = Player.Character
  101. local pm = Instance.new("Part")
  102. pm.Name = "Handle"
  103. pm.FormFactor = "Custom"
  104. pm.Size = Vector3.new(1, 1, 1)
  105. pm.BrickColor = BrickColor.new("Really black")
  106. pm.Locked = true
  107. pm.TopSurface = 0
  108. pm.BottomSurface = 0
  109. pm.Parent = beacon
  110. local m = Instance.new("SpecialMesh")
  111. m.MeshType = "Brick"
  112. m.Scale = Vector3.new(0.5, 1.25, 0.2)
  113. m.Parent = pm
  114. local w = Instance.new("Weld")
  115. w.Part0 = pm
  116. if format == "hand" then
  117. w.Part1 = Player.Character:FindFirstChild("Right Arm")
  118. w.C0 = CFrame.new(-1.2, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(90))
  119. w.C1 = CFrame.new()
  120. elseif format == "holster" then
  121. w.Part1 = Player.Character:FindFirstChild("Torso")
  122. w.C0 = CFrame.new(0.7, 0.25, 0.6)
  123. w.C1 = CFrame.new()
  124. beacon.Name = Name.. " (Holstered)"
  125. end
  126. w.Parent = pm
  127. local s = Instance.new("Sound")
  128. s.Name = "Explode"
  129. s.SoundId = "http://www.roblox.com/Asset/?id=2101148"
  130. s.Volume = 1
  131. s.Pitch = 1
  132. s.Looped = false
  133. s.Parent = pm
  134. local s = Instance.new("Sound")
  135. s.Name = "Beep"
  136. s.SoundId = "http://www.roblox.com/Asset/?id=15666462"
  137. s.Volume = 1
  138. s.Pitch = 0.75
  139. s.Looped = true
  140. s.Parent = pm
  141. local p = Instance.new("Part")
  142. p.Name = "Antenna"
  143. p.FormFactor = "Custom"
  144. p.Size = Vector3.new(1, 1, 1)
  145. p.BrickColor = BrickColor.new("Dark stone grey")
  146. p.Transparency = 0
  147. p.Locked = true
  148. p.TopSurface = 0
  149. p.BottomSurface = 0
  150. p.Parent = beacon
  151. local m = Instance.new("CylinderMesh")
  152. m.Scale = Vector3.new(0.1, 0.5, 0.1)
  153. m.Parent = p
  154. local w = Instance.new("Weld")
  155. w.Part0 = p
  156. w.Part1 = pm
  157. w.C0 = CFrame.new(0.1, -0.85, 0)
  158. w.C1 = CFrame.new()
  159. w.Parent = p
  160. local p = Instance.new("Part")
  161. p.Name = "Light"
  162. p.FormFactor = "Custom"
  163. p.Size = Vector3.new(1, 1, 1)
  164. p.BrickColor = BrickColor.new("Bright green")
  165. p.Transparency = 1
  166. p.Locked = true
  167. p.TopSurface = 0
  168. p.BottomSurface = 0
  169. p.Parent = beacon
  170. local m = Instance.new("SpecialMesh")
  171. m.MeshType = "Sphere"
  172. m.Scale = Vector3.new(0.1, 0.1, 0.1)
  173. m.Parent = p
  174. local w = Instance.new("Weld")
  175. w.Part0 = p
  176. w.Part1 = pm
  177. w.C0 = CFrame.new(-0.175, -0.64, 0)
  178. w.C1 = CFrame.new()
  179. w.Parent = p
  180. end
  181.  
  182.  
  183. function removeParts(format)
  184. if format == "hand" then
  185. if Player.Character:FindFirstChild(Name) ~= nil then
  186. Player.Character[Name]:Remove()
  187. end
  188. elseif format == "holster" then
  189. if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
  190. Player.Character[Name.. " (Holstered)"]:Remove()
  191. end
  192. end
  193. end
  194.  
  195.  
  196. function SetAngle(Joint, Angle, Character)
  197. if Character == nil then return false end
  198. local Joints = {
  199. Character.Torso:FindFirstChild("Right Shoulder 2"),
  200. Character.Torso:FindFirstChild("Left Shoulder 2"),
  201. Character.Torso:FindFirstChild("Right Hip 2"),
  202. Character.Torso:FindFirstChild("Left Hip 2")
  203. }
  204. if Joints[Joint] == nil then return false end
  205. if Joint == 1 or Joint == 3 then
  206. Joints[Joint].DesiredAngle = Angle
  207. end
  208. if Joint == 2 or Joint == 4 then
  209. Joints[Joint].DesiredAngle = -Angle
  210. end
  211. end
  212.  
  213.  
  214. function ForceAngle(Joint, Angle, Character)
  215. if Character == nil then return false end
  216. local Joints = {
  217. Character.Torso:FindFirstChild("Right Shoulder 2"),
  218. Character.Torso:FindFirstChild("Left Shoulder 2"),
  219. Character.Torso:FindFirstChild("Right Hip 2"),
  220. Character.Torso:FindFirstChild("Left Hip 2")
  221. }
  222. if Joints[Joint] == nil then return false end
  223. if Joint == 1 or Joint == 3 then
  224. Joints[Joint].DesiredAngle = Angle
  225. Joints[Joint].CurrentAngle = Angle
  226. end
  227. if Joint == 2 or Joint == 4 then
  228. Joints[Joint].DesiredAngle = -Angle
  229. Joints[Joint].CurrentAngle = -Angle
  230. end
  231. end
  232.  
  233.  
  234. function SetSpeed(Joint, Speed, Character)
  235. if Character == nil then return false end
  236. local Joints = {
  237. Character.Torso:FindFirstChild("Right Shoulder 2"),
  238. Character.Torso:FindFirstChild("Left Shoulder 2"),
  239. Character.Torso:FindFirstChild("Right Hip 2"),
  240. Character.Torso:FindFirstChild("Left Hip 2")
  241. }
  242. if Joints[Joint] == nil then return false end
  243. Joints[Joint].MaxVelocity = Speed
  244. end
  245.  
  246.  
  247. function DisableLimb(Limb, Character)
  248. if Character == nil then return false end
  249. if Character:FindFirstChild("Torso") == nil then return false end
  250. local Joints = {
  251. Character.Torso:FindFirstChild("Right Shoulder"),
  252. Character.Torso:FindFirstChild("Left Shoulder"),
  253. Character.Torso:FindFirstChild("Right Hip"),
  254. Character.Torso:FindFirstChild("Left Hip")
  255. }
  256. local Limbs = {
  257. Character:FindFirstChild("Right Arm"),
  258. Character:FindFirstChild("Left Arm"),
  259. Character:FindFirstChild("Right Leg"),
  260. Character:FindFirstChild("Left Leg")
  261. }
  262. if Joints[Limb] == nil then return false end
  263. if Limbs[Limb] == nil then return false end
  264. local Joint = Instance.new("Motor")
  265. Joint.Parent = Character.Torso
  266. Joint.Part0 = Character.Torso
  267. Joint.Part1 = Limbs[Limb]
  268. if Limb == 1 then
  269. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  270. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  271. Joint.Name = "Right Shoulder 2"
  272. elseif Limb == 2 then
  273. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  274. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  275. Joint.Name = "Left Shoulder 2"
  276. elseif Limb == 3 then
  277. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  278. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  279. Joint.Name = "Right Hip 2"
  280. elseif Limb == 4 then
  281. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  282. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  283. Joint.Name = "Left Hip 2"
  284. end
  285. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  286. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  287. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  288. Joints[Limb]:Remove()
  289. end
  290.  
  291.  
  292. function ResetLimbCFrame(Limb, Character)
  293. if Character == nil then return false end
  294. if Character.Parent == nil then return false end
  295. if Character:FindFirstChild("Torso") == nil then return false end
  296. local Joints = {
  297. Character.Torso:FindFirstChild("Right Shoulder 2"),
  298. Character.Torso:FindFirstChild("Left Shoulder 2"),
  299. Character.Torso:FindFirstChild("Right Hip 2"),
  300. Character.Torso:FindFirstChild("Left Hip 2")
  301. }
  302. local Limbs = {
  303. Character:FindFirstChild("Right Arm"),
  304. Character:FindFirstChild("Left Arm"),
  305. Character:FindFirstChild("Right Leg"),
  306. Character:FindFirstChild("Left Leg")
  307. }
  308. if Joints[Limb] == nil then return false end
  309. if Limbs[Limb] == nil then return false end
  310. if Limb == 1 then
  311. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  312. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  313. elseif Limb == 2 then
  314. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  315. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  316. elseif Limb == 3 then
  317. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  318. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  319. elseif Limb == 4 then
  320. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  321. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  322. end
  323. end
  324.  
  325.  
  326. function EnableLimb(Limb, Character)
  327. if Character == nil then return false end
  328. if Character:FindFirstChild("Torso") == nil then return false end
  329. local Joints = {
  330. Character.Torso:FindFirstChild("Right Shoulder 2"),
  331. Character.Torso:FindFirstChild("Left Shoulder 2"),
  332. Character.Torso:FindFirstChild("Right Hip 2"),
  333. Character.Torso:FindFirstChild("Left Hip 2")
  334. }
  335. local Limbs = {
  336. Character:FindFirstChild("Right Arm"),
  337. Character:FindFirstChild("Left Arm"),
  338. Character:FindFirstChild("Right Leg"),
  339. Character:FindFirstChild("Left Leg")
  340. }
  341. if Joints[Limb] == nil then return false end
  342. if Limbs[Limb] == nil then return false end
  343. if Limb == 1 then
  344. Joints[Limb].Name = "Right Shoulder"
  345. elseif Limb == 2 then
  346. Joints[Limb].Name = "Left Shoulder"
  347. elseif Limb == 3 then
  348. Joints[Limb].Name = "Right Hip"
  349. elseif Limb == 4 then
  350. Joints[Limb].Name = "Left Hip"
  351. end
  352. Animate = Character:FindFirstChild("Animate")
  353. if Animate == nil then return false end
  354. Animate = Animate:Clone()
  355. Character.Animate:Remove()
  356. Animate.Parent = Character
  357. end
  358.  
  359.  
  360. function Weld(x, y)
  361. local weld = Instance.new("Weld")
  362. weld.Part0 = x
  363. weld.Part1 = y
  364. CJ = CFrame.new(x.Position)
  365. C0 = x.CFrame:inverse() * CJ
  366. C1 = y.CFrame:inverse() * CJ
  367. weld.C0 = C0
  368. weld.C1 = C1
  369. weld.Parent = x
  370. end
  371.  
  372.  
  373. function tagHumanoid(humanoid)
  374. local tag = Instance.new("ObjectValue")
  375. tag.Name = "creator"
  376. tag.Value = Player
  377. tag.Parent = humanoid
  378. local tag = Instance.new("StringValue")
  379. tag.Name = "creatorType1"
  380. tag.Value = Name
  381. tag.Parent = humanoid
  382. local tag = Instance.new("StringValue")
  383. tag.Name = "creatorType2"
  384. tag.Value = "blown to pieces"
  385. tag.Parent = humanoid
  386. end
  387.  
  388.  
  389. function untagHumanoid(humanoid)
  390. if humanoid ~= nil then
  391. local tag = humanoid:FindFirstChild("creator")
  392. if tag ~= nil then
  393. tag:Remove()
  394. end
  395. local tag = humanoid:FindFirstChild("creatorType1")
  396. if tag ~= nil then
  397. tag:Remove()
  398. end
  399. local tag = humanoid:FindFirstChild("creatorType2")
  400. if tag ~= nil then
  401. tag:Remove()
  402. end
  403. end
  404. end
  405.  
  406.  
  407. function fire(v)
  408. if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
  409. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  410. if Player.Character[Name].Handle:FindFirstChild("Weld") ~= nil then Player.Character[Name].Handle.Weld:Remove() end
  411. local bodyVelocity = Instance.new("BodyVelocity")
  412. bodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  413. bodyVelocity.velocity = v * 75
  414. bodyVelocity.Parent = Player.Character[Name].Handle
  415. wait(0.1)
  416. bodyVelocity:Remove()
  417. end
  418.  
  419.  
  420. function onButton1Down(mouse)
  421. if selected == false then return end
  422. if Player.Character:FindFirstChild(Name) ~= nil and Button1Down ~= true and thrown ~= true then
  423. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  424. if Player.Character[Name]:FindFirstChild("Antenna") == nil then return end
  425. if Player.Character[Name]:FindFirstChild("Light") == nil then return end
  426. Button1Down = true
  427. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  428. Player.Character[Name].Light.Transparency = 0.4
  429. coroutine.resume(coroutine.create(function(target)
  430. local pos1 = target.Position
  431. local pos2 = pos1
  432. while true do
  433. if target == nil then return end
  434. if target.Parent == nil then return end
  435. pos2 = pos1
  436. pos1 = target.Position
  437. local trail = Instance.new("Part")
  438. trail.BrickColor = target.BrickColor
  439. trail.TopSurface = 0
  440. trail.BottomSurface = 0
  441. trail.FormFactor = target.FormFactor
  442. trail.Size = Vector3.new(1, 1, 1)
  443. trail.Reflectance = 0
  444. trail.Transparency = 0.3
  445. trail.Anchored = true
  446. trail.CanCollide = false
  447. trail.CFrame = CFrame.new((pos1 + pos2) / 2, pos2)
  448. trail.Parent = Workspace
  449. local mesh = Instance.new("SpecialMesh")
  450. mesh.MeshType = "Brick"
  451. mesh.Scale = Vector3.new(0.2, 0.2, (pos2 - pos1).magnitude)
  452. mesh.Parent = trail
  453. coroutine.resume(coroutine.create(function(part) for i = 3, 10, 1 do part.Transparency = i / 10 wait(0.1) end part:Remove() end), trail)
  454. wait()
  455. end
  456. end), Player.Character[Name].Light)
  457. wait(0.5)
  458. Player.Character[Name].Handle.Beep:Play()
  459. Player.Character[Name].Light.BrickColor = BrickColor.new("Bright orange")
  460. coroutine.resume(coroutine.create(function()
  461. wait(3)
  462. if Player.Character:FindFirstChild(Name) ~= nil then
  463. if Player.Character[Name]:FindFirstChild("Light") ~= nil then Player.Character[Name].Light.BrickColor = BrickColor.new("Really red") end
  464. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then Player.Character[Name].Handle.Beep.Pitch = 1.25 end
  465. local position = Player.Character[Name].Handle.Position
  466. local s = Player.Character[Name].Handle.Explode:Clone()
  467. coroutine.resume(coroutine.create(function()
  468. local weld1 = Player.Character[Name].Light:FindFirstChild("Weld")
  469. local weld2 = Player.Character[Name].Antenna:FindFirstChild("Weld")
  470. if weld1 == nil then return end
  471. if weld2 == nil then return end
  472. local weld1c = weld1:Clone()
  473. local weld2c = weld2:Clone()
  474. while true do
  475. if Player.Character ~= nil then
  476. if Player.Character:FindFirstChild(Name) ~= nil then
  477. if weld1.Parent == nil then
  478. if Player.Character[Name]:FindFirstChild("Light") ~= nil then
  479. weld1c:Clone().Parent = Player.Character[Name].Light
  480. Player.Character[Name]:MakeJoints()
  481. end
  482. end
  483. if weld2.Parent == nil then
  484. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  485. weld2c:Clone().Parent = Player.Character[Name].Antenna
  486. Player.Character[Name]:MakeJoints()
  487. end
  488. end
  489. end
  490. end
  491. wait()
  492. end
  493. end))
  494. for i = 0, math.random(30, 50) do
  495. if Player.Character:FindFirstChild("Humanoid") ~= nil then
  496. if Player.Character.Humanoid.Health <= 0 then break end
  497. local shell = Instance.new("Part")
  498. shell.Name = "Artillery Shell"
  499. shell.Anchored = true
  500. shell.BrickColor = BrickColor.new("Medium stone grey")
  501. shell.FormFactor = "Custom"
  502. shell.Size = Vector3.new(2, 5, 2)
  503. shell.TopSurface = 0
  504. shell.BottomSurface = 0
  505. shell.Parent = Workspace
  506. coroutine.resume(coroutine.create(function(part)
  507. local offset = Vector3.new(math.random(-50, 50), math.random(-10, 10), math.random(-50, 50))
  508. for i = 1000, 0, -25 do
  509. part.CFrame = CFrame.new((position + offset) + Vector3.new(0, i, 0))
  510. wait()
  511. end
  512. local e = Instance.new("Explosion")
  513. e.Position = part.Position
  514. e.BlastPressure = 500000
  515. e.BlastRadius = 25
  516. e.Parent = Workspace
  517. e.Hit:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then tagHumanoid(hit.Parent.Humanoid) delay(1, function() untagHumanoid(hit.Parent.Humanoid) end) end end)
  518. local s2 = s:Clone()
  519. s2.Pitch = math.random(70, 90) / 100
  520. s2.Parent = Workspace
  521. s2:Play()
  522. part:Remove()
  523. end), shell)
  524. end
  525. wait(math.random(1, 5) / 10)
  526. end
  527. if Player.Character:FindFirstChild(Name) ~= nil then if Player.Character[Name]:FindFirstChild("Handle") ~= nil then Player.Character[Name].Handle.Beep:Stop() end end
  528. end
  529. wait(1)
  530. removeParts("hand")
  531. wait(1)
  532. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  533. Player.Character.WeaponActivated:Remove()
  534. end
  535. thrown = false
  536. Button1Down = false
  537. selected = true
  538. onDeselected(mouse)
  539. removeParts("holster")
  540. script.Parent:Remove()
  541. end))
  542. end
  543. end
  544.  
  545.  
  546. function onButton1Up(mouse)
  547. if selected == false then return end
  548. if Button1Down == true and thrown ~= true then
  549. thrown = true
  550. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  551. SetSpeed(1, 0.75, Player.Character)
  552. SetAngle(1, 0, Player.Character)
  553. EnableLimb(1, Player.Character)
  554. fire((mouse.Hit.p - Player.Character[Name].Handle.Position).unit)
  555. end
  556. Button1Down = false
  557. end
  558.  
  559.  
  560. function onKeyDown(key, mouse)
  561. if selected == false then return end
  562. key = key:lower()
  563. if key == "q" and Button1Down == false and thrown ~= true then
  564. if mouse.Target == nil then return end
  565. if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
  566. onDeselected(mouse)
  567. removeParts("holster")
  568. script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
  569. end
  570. end
  571. end
  572.  
  573.  
  574. function onSelected(mouse)
  575. if selected == true then return end
  576. selected = true
  577. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  578. while Player.Character:FindFirstChild("WeaponActivated") ~= nil or thrown == true do
  579. if Player.Character.WeaponActivated.Value == nil then break end
  580. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  581. wait()
  582. end
  583. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  584. removeParts("holster")
  585. makeParts("hand")
  586. local weapon = Instance.new("ObjectValue")
  587. weapon.Name = "WeaponActivated"
  588. weapon.Value = script.Parent
  589. weapon.Parent = Player.Character
  590. DisableLimb(1, Player.Character)
  591. SetAngle(1, math.rad(200), Player.Character)
  592. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  593. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  594. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  595. end
  596.  
  597.  
  598. function onDeselected(mouse)
  599. if selected == false then return end
  600. selected = false
  601. while Button1Down == true or thrown == true do
  602. wait()
  603. end
  604. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  605. if Player.Character.WeaponActivated.Value == script.Parent then
  606. Player.Character.WeaponActivated:Remove()
  607. end
  608. end
  609. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  610. if Player.Character.WeaponActivated.Value == nil then break end
  611. if pcall(function() if Player.Character.WeaponActivated.Value.Parent == nil then return true end end) then break end
  612. wait()
  613. end
  614. removeParts("hand")
  615. makeParts("holster")
  616. SetAngle(1, 0, Player.Character)
  617. EnableLimb(1, Player.Character)
  618. end
  619.  
  620.  
  621. if script.Parent.ClassName ~= "HopperBin" then
  622. if Player == nil then print("Error: Player not found!") return end
  623. Tool = Instance.new("HopperBin")
  624. Tool.Name = Name
  625. Tool.Parent = Player.Backpack
  626. script.Name = "Main"
  627. script.Parent = Tool
  628. elseif script.Parent.ClassName == "HopperBin" then
  629. while script.Parent.Parent.ClassName ~= "Backpack" do
  630. wait()
  631. end
  632. Player = script.Parent.Parent.Parent
  633. makeParts("holster")
  634. script.Parent.Selected:connect(onSelected)
  635. script.Parent.Deselected:connect(onDeselected)
  636. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement