Advertisement
King_Dice

Flash Bang

Mar 1st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.18 KB | None | 0 0
  1. --[[
  2. Stun Grenade
  3. Knocks down and stuns any people in the immediate vicinity.
  4. --]]
  5.  
  6.  
  7. if script == nil then return end
  8.  
  9.  
  10. ModelName = "Stun Grenade"
  11. Player = script:FindFirstChild("Player") ~= nil and script.Player.Value or game:GetService("Players"):FindFirstChild("DarkShadow6")
  12. Selected = false
  13. Connected = false
  14. Button1Down = false
  15. CanUse = true
  16. Thrown = false
  17. FirstPerson = game:GetService("InsertService"):LoadAsset(60568552)["FirstPerson"].Value
  18. MouseAim = game:GetService("InsertService"):LoadAsset(61527949)["MouseAim"].Value
  19.  
  20.  
  21. function CheckPlayer()
  22. if Player.Character == nil then return false end
  23. if Player.Character:FindFirstChild("Torso") == nil or Player.Character:FindFirstChild("Right Arm") == nil or Player.Character:FindFirstChild("Humanoid") == nil then return false end
  24. if Player.Character.Humanoid.Health <= 0 then return false end
  25. return true
  26. end
  27.  
  28.  
  29. loadstring(game:GetService("InsertService"):LoadAsset(65363615)["tagHumanoid"].Value)()
  30.  
  31.  
  32. loadstring(game:GetService("InsertService"):LoadAsset(63178291)["CameraPunch"].Value)()
  33.  
  34.  
  35. loadstring(game:GetService("InsertService"):LoadAsset(62991657)["PacketFunctions"].Value)()
  36.  
  37.  
  38. function CreateParts(Parent, Format)
  39. if Parent == nil then return end
  40. local Parts = Instance.new("Model")
  41. Parts.Name = ModelName
  42. if Format == 1 then
  43. Parts.Name = Parts.Name.. " (Holstered)"
  44. end
  45. Parts.Parent = Parent
  46.  
  47. local MasterPart = Instance.new("Part")
  48. MasterPart.Name = "Handle"
  49. MasterPart.BrickColor = BrickColor.new("Medium stone grey")
  50. MasterPart.TopSurface = 0
  51. MasterPart.BottomSurface = 0
  52. MasterPart.FormFactor = "Custom"
  53. MasterPart.Size = Vector3.new(0.5, 0.8, 0.5)
  54. MasterPart.Parent = Parts
  55. Instance.new("CylinderMesh", MasterPart)
  56. local Weld = Instance.new("Weld")
  57. Weld.Part0 = MasterPart
  58. if Format == 1 then
  59. Weld.Part1 = Player.Character:FindFirstChild("Left Leg")
  60. Weld.C0 = CFrame.new(0.7, 0, 0.25) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
  61. elseif Format == 2 then
  62. Weld.Part1 = Player.Character:FindFirstChild("Right Arm")
  63. Weld.C0 = CFrame.new(0, 0, 1.2) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
  64. end
  65. Weld.Parent = Weld.Part0
  66.  
  67. local Part = Instance.new("Part")
  68. Part.Name = "Stripe Top"
  69. Part.BrickColor = BrickColor.new("Really black")
  70. Part.TopSurface = 0
  71. Part.BottomSurface = 0
  72. Part.FormFactor = "Custom"
  73. Part.Size = Vector3.new(0.515, 0.2, 0.515)
  74. Part.Parent = Parts
  75. Instance.new("CylinderMesh", Part).Scale = Vector3.new(1, 0.1, 1)
  76. local Weld = Instance.new("Weld")
  77. Weld.Part0 = Part
  78. Weld.Part1 = MasterPart
  79. Weld.Parent = Weld.Part0
  80.  
  81. local Part = Instance.new("Part")
  82. Part.Name = "Stripe Bottom"
  83. Part.BrickColor = BrickColor.new("Really black")
  84. Part.TopSurface = 0
  85. Part.BottomSurface = 0
  86. Part.FormFactor = "Custom"
  87. Part.Size = Vector3.new(0.515, 0.2, 0.515)
  88. Part.Parent = Parts
  89. Instance.new("CylinderMesh", Part).Scale = Vector3.new(1, 0.1, 1)
  90. local Weld = Instance.new("Weld")
  91. Weld.Part0 = Part
  92. Weld.Part1 = MasterPart
  93. Weld.C0 = CFrame.new(0, 0.4, 0)
  94. Weld.Parent = Weld.Part0
  95.  
  96. local Part = Instance.new("Part")
  97. Part.Name = "Stripe Center"
  98. Part.BrickColor = BrickColor.new("Bright blue")
  99. Part.TopSurface = 0
  100. Part.BottomSurface = 0
  101. Part.FormFactor = "Custom"
  102. Part.Size = Vector3.new(0.51, 0.4, 0.51)
  103. Part.Parent = Parts
  104. Instance.new("CylinderMesh", Part)
  105. local Weld = Instance.new("Weld")
  106. Weld.Part0 = Part
  107. Weld.Part1 = MasterPart
  108. Weld.C0 = CFrame.new(0, 0.2, 0)
  109. Weld.Parent = Weld.Part0
  110.  
  111. local Part = Instance.new("Part")
  112. Part.Name = "Pin Holder"
  113. Part.BrickColor = BrickColor.new("Dark stone grey")
  114. Part.TopSurface = 0
  115. Part.BottomSurface = 0
  116. Part.FormFactor = "Custom"
  117. Part.Size = Vector3.new(0.2, 0.4, 0.2)
  118. Part.Parent = Parts
  119. Instance.new("CylinderMesh", Part)
  120. local Weld = Instance.new("Weld")
  121. Weld.Part0 = Part
  122. Weld.Part1 = MasterPart
  123. Weld.C0 = CFrame.new(0, -0.5, 0)
  124. Weld.Parent = Weld.Part0
  125.  
  126. local MasterPart2 = Instance.new("Part")
  127. MasterPart2.Name = "Pin"
  128. MasterPart2.BrickColor = BrickColor.new("Dark stone grey")
  129. MasterPart2.TopSurface = 0
  130. MasterPart2.BottomSurface = 0
  131. MasterPart2.FormFactor = "Custom"
  132. MasterPart2.Size = Vector3.new(0.2, 0.2, 0.2)
  133. MasterPart2.Parent = Parts
  134. local Mesh = Instance.new("SpecialMesh", MasterPart2)
  135. Mesh.MeshType = "Brick"
  136. Mesh.Scale = Vector3.new(0.3, 0.1, 0.1)
  137. local Weld = Instance.new("Weld")
  138. Weld.Part0 = MasterPart2
  139. Weld.Part1 = MasterPart
  140. Weld.C0 = CFrame.new(0.125, -0.6, 0)
  141. Weld.Parent = Weld.Part0
  142.  
  143. local Part = Instance.new("Part")
  144. Part.Name = "Pin Ring"
  145. Part.BrickColor = BrickColor.new("Dark stone grey")
  146. Part.TopSurface = 0
  147. Part.BottomSurface = 0
  148. Part.FormFactor = "Custom"
  149. Part.Size = Vector3.new(0.2, 0.2, 0.2)
  150. Part.Parent = Parts
  151. Instance.new("CylinderMesh", Part).Scale = Vector3.new(0.75, 0.1, 0.75)
  152. local Weld = Instance.new("Weld")
  153. Weld.Part0 = Part
  154. Weld.Part1 = MasterPart2
  155. Weld.C0 = CFrame.new(0.1, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
  156. Weld.Parent = Weld.Part0
  157.  
  158. for _, Part in pairs(Parts:GetChildren()) do
  159. Part.Locked = true
  160. Part.CanCollide = false
  161. end
  162. end
  163.  
  164.  
  165. function RemoveParts(Parent, Format)
  166. if Format == 1 then
  167. pcall(function() Parent[ModelName.. " (Holstered)"]:Remove() end)
  168. elseif Format == 2 then
  169. pcall(function() Parent[ModelName]:Remove() end)
  170. end
  171. end
  172.  
  173.  
  174. function SetAngle(Joint, Angle, Character)
  175. if Character == nil then return false end
  176. local Joints = {
  177. Character.Torso:FindFirstChild("Right Shoulder 2"),
  178. Character.Torso:FindFirstChild("Left Shoulder 2"),
  179. Character.Torso:FindFirstChild("Right Hip 2"),
  180. Character.Torso:FindFirstChild("Left Hip 2")
  181. }
  182. if Joints[Joint] == nil then return false end
  183. if Joint == 1 or Joint == 3 then
  184. Joints[Joint].DesiredAngle = Angle
  185. end
  186. if Joint == 2 or Joint == 4 then
  187. Joints[Joint].DesiredAngle = -Angle
  188. end
  189. end
  190.  
  191.  
  192. function ForceAngle(Joint, Angle, Character)
  193. if Character == nil then return false end
  194. local Joints = {
  195. Character.Torso:FindFirstChild("Right Shoulder 2"),
  196. Character.Torso:FindFirstChild("Left Shoulder 2"),
  197. Character.Torso:FindFirstChild("Right Hip 2"),
  198. Character.Torso:FindFirstChild("Left Hip 2")
  199. }
  200. if Joints[Joint] == nil then return false end
  201. if Joint == 1 or Joint == 3 then
  202. Joints[Joint].DesiredAngle = Angle
  203. Joints[Joint].CurrentAngle = Angle
  204. end
  205. if Joint == 2 or Joint == 4 then
  206. Joints[Joint].DesiredAngle = -Angle
  207. Joints[Joint].CurrentAngle = -Angle
  208. end
  209. end
  210.  
  211.  
  212. function SetSpeed(Joint, Speed, Character)
  213. if Character == nil then return false end
  214. local Joints = {
  215. Character.Torso:FindFirstChild("Right Shoulder 2"),
  216. Character.Torso:FindFirstChild("Left Shoulder 2"),
  217. Character.Torso:FindFirstChild("Right Hip 2"),
  218. Character.Torso:FindFirstChild("Left Hip 2")
  219. }
  220. if Joints[Joint] == nil then return false end
  221. Joints[Joint].MaxVelocity = Speed
  222. end
  223.  
  224.  
  225. function DisableLimb(Limb, Character)
  226. if Character == nil then return false end
  227. if Character:FindFirstChild("Torso") == nil then return false end
  228. local Joints = {
  229. Character.Torso:FindFirstChild("Right Shoulder"),
  230. Character.Torso:FindFirstChild("Left Shoulder"),
  231. Character.Torso:FindFirstChild("Right Hip"),
  232. Character.Torso:FindFirstChild("Left Hip")
  233. }
  234. local Limbs = {
  235. Character:FindFirstChild("Right Arm"),
  236. Character:FindFirstChild("Left Arm"),
  237. Character:FindFirstChild("Right Leg"),
  238. Character:FindFirstChild("Left Leg")
  239. }
  240. if Joints[Limb] == nil then return false end
  241. if Limbs[Limb] == nil then return false end
  242. local Joint = Instance.new("Motor6D")
  243. Joint.Parent = Character.Torso
  244. Joint.Part0 = Character.Torso
  245. Joint.Part1 = Limbs[Limb]
  246. if Limb == 1 then
  247. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  248. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  249. Joint.Name = "Right Shoulder 2"
  250. elseif Limb == 2 then
  251. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  252. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  253. Joint.Name = "Left Shoulder 2"
  254. elseif Limb == 3 then
  255. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  256. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  257. Joint.Name = "Right Hip 2"
  258. elseif Limb == 4 then
  259. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  260. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  261. Joint.Name = "Left Hip 2"
  262. end
  263. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  264. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  265. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  266. Joints[Limb]:Remove()
  267. end
  268.  
  269.  
  270. function ResetLimbCFrame(Limb, Character)
  271. if Character == nil then return false end
  272. if Character.Parent == nil then return false end
  273. if Character:FindFirstChild("Torso") == nil then return false end
  274. local Joints = {
  275. Character.Torso:FindFirstChild("Right Shoulder 2"),
  276. Character.Torso:FindFirstChild("Left Shoulder 2"),
  277. Character.Torso:FindFirstChild("Right Hip 2"),
  278. Character.Torso:FindFirstChild("Left Hip 2")
  279. }
  280. local Limbs = {
  281. Character:FindFirstChild("Right Arm"),
  282. Character:FindFirstChild("Left Arm"),
  283. Character:FindFirstChild("Right Leg"),
  284. Character:FindFirstChild("Left Leg")
  285. }
  286. if Joints[Limb] == nil then return false end
  287. if Limbs[Limb] == nil then return false end
  288. if Limb == 1 then
  289. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  290. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  291. elseif Limb == 2 then
  292. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  293. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  294. elseif Limb == 3 then
  295. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  296. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  297. elseif Limb == 4 then
  298. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  299. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  300. end
  301. end
  302.  
  303.  
  304. function EnableLimb(Limb, Character)
  305. if Character == nil then return false end
  306. if Character:FindFirstChild("Torso") == nil then return false end
  307. local Joints = {
  308. Character.Torso:FindFirstChild("Right Shoulder 2"),
  309. Character.Torso:FindFirstChild("Left Shoulder 2"),
  310. Character.Torso:FindFirstChild("Right Hip 2"),
  311. Character.Torso:FindFirstChild("Left Hip 2")
  312. }
  313. local Limbs = {
  314. Character:FindFirstChild("Right Arm"),
  315. Character:FindFirstChild("Left Arm"),
  316. Character:FindFirstChild("Right Leg"),
  317. Character:FindFirstChild("Left Leg")
  318. }
  319. if Joints[Limb] == nil then return false end
  320. if Limbs[Limb] == nil then return false end
  321. if Limb == 1 then
  322. Joints[Limb].Name = "Right Shoulder"
  323. elseif Limb == 2 then
  324. Joints[Limb].Name = "Left Shoulder"
  325. elseif Limb == 3 then
  326. Joints[Limb].Name = "Right Hip"
  327. elseif Limb == 4 then
  328. Joints[Limb].Name = "Left Hip"
  329. end
  330. Animate = Character:FindFirstChild("Animate")
  331. if Animate == nil then return false end
  332. Animate = Animate:Clone()
  333. Character.Animate:Remove()
  334. Animate.Parent = Character
  335. end
  336.  
  337.  
  338. function onButton1Down(Mouse)
  339. if Button1Down == true then return end
  340. Button1Down = true
  341. if CheckPlayer() == false or Primed == true or Thrown == true or CanUse == false then return end
  342. CanUse = false
  343. Primed = true
  344. SoundToServer("Pin", "http://www.roblox.com/Asset/?id=2697295", 5, 1, false, Player.Character.Torso)
  345. pcall(function() Player.Character[ModelName].Pin.Weld:Remove() end)
  346. for _, Part in pairs(Player.Character[ModelName]:GetChildren()) do
  347. pcall(function()
  348. if string.match(Part.Name, "Pin") then
  349. Part.CanCollide = true
  350. end
  351. end)
  352. end
  353. Instance.new("Configuration", Player.Character[ModelName].Handle).Name = "CanExplode"
  354. SendToServer([[MaxDistance = 50
  355. wait(4)
  356. if Source.Parent == nil then return end
  357. Source.Parent.Parent = Workspace
  358. pcall(function() Source.Weld:Remove() end)
  359. for _, Part in pairs(Source.Parent:GetChildren()) do
  360. if Part ~= Source then
  361. Part:Remove()
  362. end
  363. end
  364. Source.Anchored = true
  365. Source.Transparency = 1
  366. Source.CanCollide = false
  367. Source.CFrame = CFrame.new(Source.Position)
  368. local Sound = Instance.new("Sound")
  369. Sound.Name = "Bang"
  370. Sound.SoundId = "rbxasset://sounds/collide.wav"
  371. Sound.Volume = 1
  372. Sound.Pitch = 3
  373. Sound.Parent = Source
  374. Sound:Play()
  375. game:GetService("Debris"):AddItem(Sound, 0.1)
  376. local Part = Instance.new("Part", Source.Parent)
  377. Part.Name = "Bang"
  378. Part.BrickColor = BrickColor.new("Institutional white")
  379. Part.TopSurface = 0
  380. Part.BottomSurface = 0
  381. Part.CanCollide = false
  382. Part.Anchored = true
  383. Part.FormFactor = "Custom"
  384. Part.Size = Vector3.new(1, 1, 1)
  385. Part.CFrame = Source.CFrame
  386. Instance.new("SpecialMesh", Part).MeshType = "Sphere"
  387. coroutine.wrap(function()
  388. for i = 0, 1, 0.15 do
  389. Part.Mesh.Scale = Vector3.new(i, i, i) * (MaxDistance + 5)
  390. Part.Transparency = i
  391. wait()
  392. end
  393. Part:Remove()
  394. end)()
  395. local Smoke = Instance.new("Smoke", Source)
  396. Smoke.Color = Color3.new(0.8, 0.8, 0.8)
  397. Smoke.Size = 15
  398. Smoke.RiseVelocity = 10
  399. Smoke.Opacity = 0.2
  400. for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
  401. if Player.Character ~= nil then
  402. if Player.Character:FindFirstChild("Torso") ~= nil and Player.Character:FindFirstChild("Humanoid") ~= nil then
  403. local Distance = (Player.Character.Torso.Position - Source.Position).magnitude
  404. if Distance < MaxDistance then
  405. local Down = true
  406. Player.Character.Torso.Friction = 0.5
  407. Player.Character.Humanoid.PlatformStand = true
  408. Player.Character.Humanoid.Changed:connect(function(Property)
  409. if Property == "PlatformStand" and Player.Character.Humanoid.PlatformStand == false and Down == true then
  410. Player.Character.Humanoid.PlatformStand = true
  411. end
  412. end)
  413. wait()
  414. Player.Character.Torso.Velocity = Player.Character.Torso.Velocity + ((Player.Character.Torso.Position - Source.Position).unit * 75 * ((MaxDistance - Distance) / MaxDistance))
  415. coroutine.wrap(function()
  416. wait(((MaxDistance - Distance) / MaxDistance) * 10)
  417. Down = false
  418. Player.Character.Torso.Friction = 0
  419. Player.Character.Humanoid.PlatformStand = false
  420. end)()
  421. end
  422. end
  423. end
  424. end
  425. wait(1)
  426. Smoke.Enabled = false
  427. wait(5)
  428. Source.Parent:Remove()]], "Stun", {"Source", Player.Character[ModelName].Handle})
  429. Player.Character[ModelName].Changed:connect(function(Property)
  430. if Property == "Parent" then
  431. while CanUse == false do wait() end
  432. EnableLimb(1, Player.Character)
  433. UpdateFirstPerson()
  434. script.Parent:Remove()
  435. end
  436. end)
  437. CanUse = true
  438. end
  439.  
  440.  
  441. function onButton1Up(Mouse)
  442. if Button1Down == false then return end
  443. Button1Down = false
  444. if CanUse == false then return end
  445. if Player.Character:FindFirstChild(ModelName) ~= nil and Thrown == false then
  446. Thrown = true
  447. SetSpeed(1, 0.75, Player.Character)
  448. SetAngle(1, 0, Player.Character)
  449. wait()
  450. pcall(function() Player.Character[ModelName].Handle.Weld:Remove() end)
  451. for _, Part in pairs(Player.Character[ModelName]:GetChildren()) do
  452. pcall(function() Part.CanCollide = true end)
  453. end
  454. local BodyVelocity = Instance.new("BodyVelocity")
  455. BodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  456. BodyVelocity.velocity = (Mouse.Hit.p - Player.Character[ModelName].Handle.Position).unit * 75
  457. BodyVelocity.Parent = Player.Character[ModelName].Handle
  458. game:GetService("Debris"):AddItem(BodyVelocity, 0.1)
  459. game:GetService("Debris"):AddItem(Player.Character[ModelName], 10)
  460. Player.Character[ModelName].Parent = Workspace
  461. end
  462. end
  463.  
  464.  
  465. function onKeyDown(Key, Mouse)
  466. if Selected == false then return end
  467. Key = Key:lower()
  468. if Button1Down == false and CanUse == true and CheckPlayer() == true then
  469. if Key == "q" then
  470. if Mouse.Target == nil then return end
  471. if CheckPlayer() == false then return end
  472. local NewPlayer = game:GetService("Players"):GetPlayerFromCharacter(Mouse.Target.Parent)
  473. if NewPlayer == nil then return end
  474. if NewPlayer.Character == nil then return end
  475. if NewPlayer.Character:FindFirstChild("Torso") == nil then return end
  476. if (NewPlayer.Character.Torso.Position - Player.Character.Torso.Position).magnitude > 10 then return end
  477. onDeselected(Mouse)
  478. wait()
  479. RemoveParts(Player.Character, 1)
  480. script.Parent.Parent = NewPlayer.Backpack
  481. Player = NewPlayer
  482. elseif Key == "g" then
  483. CanUse = false
  484. SoundToServer("Slash", "rbxasset://sounds/swordslash.wav", 2, 1, false, Player.Character.Torso)
  485. SetSpeed(1, 0.75, Player.Character)
  486. SetAngle(1, 0, Player.Character)
  487. local HasHit = false
  488. local _, HitConnection = pcall(function() return Player.Character[ModelName].Handle.Touched:connect(function(Hit)
  489. if HasHit == true or Hit:IsDescendantOf(Player.Character) then return end
  490. HasHit = true
  491. SoundToServer("Bash", "http://www.roblox.com/Asset/?id=46153268", 1, 0.25, false, Player.Character.Torso)
  492. local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
  493. if Humanoid ~= nil then
  494. tagHumanoid(Humanoid)
  495. Humanoid:TakeDamage(7)
  496. wait()
  497. pcall(function() untagHumanoid(Humanoid) end)
  498. end
  499. end) end)
  500. CameraSlide(math.rad(-15), 0, 0.2)
  501. pcall(function() HitConnection:disconnect() end)
  502. SetSpeed(1, 0.5, Player.Character)
  503. SetAngle(1, math.rad(200), Player.Character)
  504. CameraSlide(math.rad(15), 0, 0.25)
  505. CanUse = true
  506. end
  507. end
  508. end
  509.  
  510.  
  511. function onSelected(Mouse)
  512. if Selected == true or CanUse == false then return end
  513. CanUse = false
  514. while true do
  515. if CheckPlayer() == true then
  516. if Player.Character.Torso:FindFirstChild("Right Shoulder") ~= nil then
  517. break
  518. end
  519. end
  520. wait(0.1)
  521. end
  522. Selected = true
  523. RemoveParts(Player.Character, 1)
  524. CreateParts(Player.Character, 2)
  525. DisableLimb(1, Player.Character)
  526. SetSpeed(1, 0.5, Player.Character)
  527. SetAngle(1, math.rad(200), Player.Character)
  528. Mouse.Icon = "rbxasset://textures\\GunCursor.png"
  529. Mouse.Button1Down:connect(function() onButton1Down(Mouse) end)
  530. Mouse.Button1Up:connect(function() onButton1Up(Mouse) end)
  531. Mouse.KeyDown:connect(function(Key) onKeyDown(Key, Mouse) end)
  532. CanUse = true
  533. end
  534.  
  535.  
  536. function onDeselected(Mouse)
  537. if Selected == false or Primed == true then return end
  538. Selected = false
  539. while CanUse == false do wait() end
  540. if Selected == true then return end
  541. CanUse = false
  542. RemoveParts(Player.Character, 2)
  543. CreateParts(Player.Character, 1)
  544. SetAngle(1, 0, Player.Character)
  545. ResetLimbCFrame(1, Player.Character)
  546. EnableLimb(1, Player.Character)
  547. CanUse = true
  548. end
  549.  
  550.  
  551. if script.Parent.ClassName ~= "HopperBin" then
  552. if Player == nil then print("Error: Player not found!") return end
  553. Tool = Instance.new("HopperBin")
  554. Tool.Name = ModelName
  555. Tool.Parent = Player.Backpack
  556. script.Name = "Main"
  557. script.Parent = Tool
  558. elseif script.Parent.ClassName == "HopperBin" and Connected == false then
  559. Connected = true
  560. Player = script.Parent.Parent.Parent
  561. script.Parent.Selected:connect(onSelected)
  562. script.Parent.Deselected:connect(onDeselected)
  563. CreateParts(Player.Character, 1)
  564. coroutine.wrap(loadstring(FirstPerson))()
  565. coroutine.wrap(loadstring(MouseAim))()
  566. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement