Advertisement
TheUnknownDiscord

gravity gun

Apr 22nd, 2022
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.73 KB | None | 0 0
  1. tool2 = Instance.new("Tool",owner.Backpack)
  2. tool2.Name = "Crowbar"
  3. local partt = Instance.new("Part",tool2)
  4. partt.Name = "Handle"
  5. local hitdb = false
  6. partt.Size = Vector3.new(0.2,3.2,0.6)
  7. tool2.Grip = CFrame.new(0,-0.15,-0.15) * CFrame.Angles(0,math.rad(180),0)
  8. local mm = Instance.new("SpecialMesh",partt)
  9. mm.TextureId = "rbxassetid://441564112"
  10. mm.MeshId = "rbxassetid://441564090"
  11. mm.Scale = Vector3.new(0.015, 0.015, 0.015)
  12. local launch = {"7449437191","7449437048","7449436988","7449436902"}
  13. local pickup = "7449454869"
  14. local drop = "7449454513"
  15. tool = Instance.new("Tool",owner.Backpack)
  16. tool.Name = "Gravity Gun"
  17. tool.Grip = CFrame.new(0.45,-0.5,2) * CFrame.Angles(0,math.rad(10),0)
  18. local part = Instance.new("Part",tool)
  19. part.Reflectance = 0.125
  20. part.Name = "Handle"
  21. part.Size = Vector3.new(1.6048,1.0809,3.1887) * 1.5
  22. local p2 = Instance.new("Part",part)
  23. p2.Shape = "Cylinder"
  24. p2.Size = Vector3.new(1.5,0.85,0.85)
  25. p2.CanCollide = false
  26. p2.Massless = true
  27. p2.Color = Color3.fromRGB(255,100,0)
  28. p2.Reflectance = 0.125
  29. p2.Material = "Neon"
  30. local wel = Instance.new("Weld",part)
  31. wel.Part0 = p2
  32. wel.Part1 = part
  33. wel.C1 = CFrame.new(0.25,-0.25,-0.25) * CFrame.Angles(0,math.rad(90),0)
  34. TweenService = game:GetService("TweenService")
  35. spininfo = TweenInfo.new(0.25,Enum.EasingStyle.Linear)
  36.  
  37. Spin1 = TweenService:Create(wel,spininfo,{C1 = wel.C1 * CFrame.Angles(math.rad(120),0,0)})
  38. Spin2 = TweenService:Create(wel,spininfo,{C1 = wel.C1 * CFrame.Angles(math.rad(240),0,0)})
  39. Spin3 = TweenService:Create(wel,spininfo,{C1 = wel.C1 * CFrame.Angles(math.rad(360),0,0)})
  40.  
  41. Spin1.Completed:Connect(function()Spin2:Play() end)
  42. Spin2.Completed:Connect(function()Spin3:Play() end)
  43. Spin3.Completed:Connect(function()Spin1:Play() end)
  44. Spin1:Play()
  45. local p3 = Instance.new("Part",part)
  46. p3.CanCollide = false
  47. p3.Massless = true
  48. p3.Transparency = 0.9
  49. p3.Color = Color3.fromRGB(230,230,230)
  50. local m3 = Instance.new("SpecialMesh",p3)
  51. m3.MeshId = "rbxassetid://7442685765"
  52. m3.Scale = Vector3.new(0.25,0.25,0.25)
  53. local wel2 = Instance.new("Weld",part)
  54. wel2.Part0 = p3
  55. wel2.Part1 = part
  56. wel2.C0 = CFrame.new(0.25,0.5,-2) * CFrame.Angles(math.rad(-40),math.rad(180),0)
  57. wel2.C1 = CFrame.new(0,1.4,0)
  58. local m = Instance.new("SpecialMesh",part)
  59. m.TextureId = "rbxassetid://7442695635"
  60. m.MeshId = "rbxassetid://7442685591"
  61. m.Scale = Vector3.new(0.1125,0.1125,0.1125)
  62. local sound = Instance.new("Sound")
  63. sound.Volume = 1.25
  64. local s = Instance.new("Sound",part)
  65. s.Volume = 1.5
  66. s.Looped = true
  67. s.SoundId = "rbxassetid://7449423195"
  68. sound.PlayOnRemove = true
  69. p = Instance.new("Part",owner. Character)
  70. p.CanCollide = false
  71. p.Size = Vector3.new(0.01,0.01,0.01)
  72. p.Transparency = 1
  73. a2 = Instance.new("Part",owner. Character)
  74. a2.CanCollide = false
  75. a2.Size = Vector3.new(0.01,0.01,0.01)
  76. a2.Transparency = 1
  77. a = Instance.new("Part",owner. Character)
  78. a.CanCollide = false
  79. a.Size = Vector3.new(0.01,0.01,0.01)
  80. a.Transparency = 1
  81. local weldd = Instance.new("Weld", a)
  82. weldd.Part0 = p
  83. weldd.Part1 = a
  84. local weldd2 = Instance.new("Weld", owner.Character.Torso)
  85. weldd2.Part0 = a
  86. weldd2.Part1 = owner.Character.Torso
  87. local weldd3 = Instance.new("Weld", owner.Character.Torso)
  88. weldd3.Part0 = a2
  89. weldd3.Part1 = owner.Character.Torso
  90. weldd3.C1 = CFrame.new(1.5,0.5,0)
  91. local headd = Instance.new("Weld", owner.Character.Torso)
  92. headd.Part0 = owner.Character.Head
  93. headd.Part1 = owner.Character.Torso
  94. headd.C1 = CFrame.new(0,1,0)
  95. local weld = Instance.new("Weld", p)
  96. weld.Part0 = p
  97. weld.Part1 = owner.Character["Right Arm"]
  98. weld.C0 = CFrame.new(1.45, 0.5, -0.85) * CFrame.Angles(math.rad(90),0,math.rad(-10))
  99. local weld2 = Instance.new("Weld", p)
  100. weld2.Part0 = p
  101. weld2.Part1 = owner.Character["Left Arm"]
  102. weld2.C0 = CFrame.new(-0.35, 0.45, -1.65) * CFrame.Angles(math.rad(95),math.rad(10),math.rad(20))
  103. local weld3 = Instance.new("Weld", a2)
  104. weld3.Part0 = a2
  105. weld3.Part1 = owner.Character["Right Arm"]
  106. weld3.C0 = CFrame.new(0, 0, -0.5) * CFrame.Angles(math.rad(90),0,0)
  107. weld2.Enabled = false
  108. weld3.Enabled = false
  109. weld.Enabled = false
  110. tool2.Equipped:Connect(function()
  111. weld3.Enabled = true
  112. sound.PlaybackSpeed = 1
  113. sound.Volume = 1.5
  114. sound.SoundId = "rbxassetid://769464514"
  115. sound.Parent = partt
  116. sound.Parent = nil
  117. end)
  118. tool2.Unequipped:Connect(function()
  119. weld3.Enabled = false
  120. end)
  121. tool.Equipped:Connect(function()
  122. weld2.Enabled = true
  123. weld.Enabled = true
  124. sound.PlaybackSpeed = 1
  125. sound.Volume = 1.5
  126. sound.SoundId = "rbxassetid://7449454666"
  127. sound.Parent = part
  128. sound.Parent = nil
  129. end)
  130. local tweenService = game:GetService("TweenService")
  131. local timeToFade = 0.25
  132. local object = weld
  133. local object2 = weld2
  134. local tweenInfo = TweenInfo.new(timeToFade,Enum.EasingStyle.Quint,Enum.EasingDirection.InOut)
  135. local tweenInfo2 = TweenInfo.new(timeToFade,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)
  136. local goal = {}
  137. goal.C0 = CFrame.new(1.45, 0.65, -0.2) * CFrame.Angles(math.rad(100),0,math.rad(-10))
  138. local tween1 = tweenService:Create(object, tweenInfo, goal)
  139. local goal2 = {}
  140. goal2.C0 = CFrame.new(-0.35, 0.55, -1) * CFrame.Angles(math.rad(105),math.rad(10),math.rad(20))
  141. local tween2 = tweenService:Create(object2, tweenInfo, goal2)
  142. local goal3 = {}
  143. goal3.C0 = CFrame.new(1.45, 0.5, -0.85) * CFrame.Angles(math.rad(90),0,math.rad(-10))
  144. local tween3 = tweenService:Create(object, tweenInfo2, goal3)
  145. local goal4 = {}
  146. goal4.C0 = CFrame.new(-0.35, 0.45, -1.65) * CFrame.Angles(math.rad(95),math.rad(10),math.rad(20))
  147. local tween4 = tweenService:Create(object2, tweenInfo2, goal4)
  148. tween1.Completed:Connect(function()
  149. tween3:Play()
  150. tween4:Play()
  151. end)
  152. local candamage = false
  153. tool2.Activated:Connect(function()
  154. if not candamage then
  155. candamage = true
  156. sound.PlaybackSpeed = 1
  157. sound.Volume = 1.5
  158. sound.SoundId = "rbxassetid://2156366946"
  159. sound.Parent = partt
  160. sound.Parent = nil
  161. local gs = {}
  162. local s = math.random(-10,10)
  163. if (s < 5 and s > -5) then
  164. repeat
  165. s = math.random(-10,10)
  166. until not (s < 5 and s > -5)
  167. end
  168. gs.C0 = CFrame.new(0, 0, -0.75) * CFrame.Angles(math.rad(90),math.rad(s),math.rad(0)) * CFrame.new(0,0,0.25)
  169. local tt = tweenService:Create(weld3, TweenInfo.new(0.125,Enum.EasingStyle.Quint,Enum.EasingDirection.Out), gs)
  170. tt:Play()
  171. tt.Completed:Wait()
  172. local gs = {}
  173. gs.C0 = CFrame.new(0, 0, -0.5) * CFrame.Angles(math.rad(90),math.rad(0),math.rad(0))
  174. local tt = tweenService:Create(weld3, TweenInfo.new(0.125,Enum.EasingStyle.Quint,Enum.EasingDirection.In), gs)
  175. tt:Play()
  176. tt.Completed:Wait()
  177. candamage = false
  178. hitdb = false
  179. end
  180. end)
  181. local speed = 1
  182. local speed2 = 0
  183. local g = {}
  184. g.C1 = CFrame.new(0, 0.1, 0) * CFrame.Angles(0,0,math.rad(2))
  185. local t = tweenService:Create(weldd, TweenInfo.new(5,Enum.EasingStyle.Quad,Enum.EasingDirection.In), g)
  186. local g2 = {}
  187. g2.C1 = CFrame.new(0, 0, 0) * CFrame.Angles(0,0,math.rad(-2))
  188. local t2 = tweenService:Create(weldd, TweenInfo.new(5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out), g2)
  189. local g3 = {}
  190. g3.C1 = CFrame.Angles(math.rad(-2),math.rad(2),0)
  191. local t3 = tweenService:Create(weldd2, TweenInfo.new(0.125,Enum.EasingStyle.Linear,Enum.EasingDirection.In), g3)
  192. local g4 = {}
  193. g4.C1 = CFrame.Angles(math.rad(-2),math.rad(-2),0)
  194. local t4 = tweenService:Create(weldd2, TweenInfo.new(0.25,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), g4)
  195. local g5 = {}
  196. g5.C1 = CFrame.Angles(0,math.rad(0),0)
  197. local t5 = tweenService:Create(weldd2, TweenInfo.new(0.25,Enum.EasingStyle.Linear,Enum.EasingDirection.In), g5)
  198. local t6 = tweenService:Create(weldd2, TweenInfo.new(0.25,Enum.EasingStyle.Linear,Enum.EasingDirection.In), g3)
  199. t:Play()
  200. local walking = false
  201. t.Completed:Connect(function()
  202. t2:Play()
  203. end)
  204. t2.Completed:Connect(function()
  205. t:Play()
  206. end)
  207. t3.Completed:Connect(function()
  208. if walking then
  209. t4:Play()
  210. else
  211. t5:Play()
  212. end
  213. end)
  214. t4.Completed:Connect(function()
  215. if walking then
  216. t6:Play()
  217. else
  218. t5:Play()
  219. end
  220. end)
  221. t6.Completed:Connect(function()
  222. if walking then
  223. t4:Play()
  224. else
  225. t5:Play()
  226. end
  227. end)
  228. owner.Character.Humanoid.Changed:Connect(function()
  229. if owner.Character.Humanoid.MoveDirection ~= Vector3.new(0,0,0) and owner.Character:FindFirstChildWhichIsA("Part").Velocity.Magnitude <= 0 then
  230. walking = true
  231. t3:Play()
  232. elseif owner.Character.Humanoid.MoveDirection == Vector3.new(0,0,0) then
  233. walking = false
  234. end
  235. end)
  236. beam1 = Instance.new("Beam",part)
  237. beam1.Texture = "rbxassetid://1274380363"
  238. beam1.TextureMode = "Stretch"
  239. beam1.TextureLength = 1
  240. beam1.TextureSpeed = -10
  241. beam1.LightEmission = 1
  242. beam1.CurveSize0 = 0
  243. beam1.CurveSize1 = 0
  244. beam1.Width0 = 0.125
  245. beam1.Width1 = 0.25
  246. beam1.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, 0.35), NumberSequenceKeypoint.new(1, 0.75)}
  247. beam1.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 100,0)),ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 100,0))}
  248. beam2 = Instance.new("Beam",part)
  249. beam2.Texture = "rbxassetid://1274380363"
  250. beam2.TextureMode = "Stretch"
  251. beam2.TextureLength = 1
  252. beam2.TextureSpeed = -10
  253. beam2.LightEmission = 1
  254. beam2.CurveSize0 = 0
  255. beam2.CurveSize1 = 0
  256. beam2.Width0 = 0.125
  257. beam2.Width1 = 0.25
  258. beam2.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, 0.35), NumberSequenceKeypoint.new(1, 0.75)}
  259. beam2.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 100,0)),ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 100,0))}
  260. beam3 = Instance.new("Beam",part)
  261. beam3.Texture = "rbxassetid://1274380363"
  262. beam3.TextureMode = "Stretch"
  263. beam3.TextureLength = 1
  264. beam3.TextureSpeed = -10
  265. beam3.LightEmission = 1
  266. beam3.CurveSize0 = 0
  267. beam3.CurveSize1 = 0
  268. beam3.Width0 = 0.125
  269. beam3.Width1 = 0.25
  270. beam3.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, 0.35), NumberSequenceKeypoint.new(1, 0.75)}
  271. beam3.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 100,0)),ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 100,0))}
  272. beam1.FaceCamera = true
  273. beam2.FaceCamera = true
  274. beam3.FaceCamera = true
  275. local at = Instance.new("Attachment",part)
  276. at.CFrame = CFrame.new(0.25,0.6,-2.35)
  277. local at2 = Instance.new("Attachment",part)
  278. at2.CFrame = CFrame.new(1.025,-0.7,-2.35)
  279. local at3 = Instance.new("Attachment",part)
  280. at3.CFrame = CFrame.new(-0.525,-0.7,-2.35)
  281. beam1.Attachment0 = at
  282. beam2.Attachment0 = at2
  283. beam3.Attachment0 = at3
  284. tool.Unequipped:Connect(function()
  285. weld2.Enabled = false
  286. weld.Enabled = false
  287. sound.PlaybackSpeed = 1
  288. sound.Volume = 1.5
  289. sound.SoundId = "rbxassetid://7449454594"
  290. sound.Parent = part
  291. sound.Parent = nil
  292. end)
  293. local attachment2 = Instance.new("Attachment",part)
  294. attachment2.CFrame = CFrame.new(0.25,-0.25,-1.25)
  295. local attachment3 = Instance.new("Attachment",part)
  296. attachment3.CFrame = CFrame.new(0.25,-0.25,-2.25)
  297. local align = nil
  298. local align2 = nil
  299. local sparks = ColorSequence.new{ColorSequenceKeypoint.new(0,Color3.fromRGB(255, 100, 0)),ColorSequenceKeypoint.new(0.75,Color3.fromRGB(225, 75, 0)),ColorSequenceKeypoint.new(1,Color3.fromRGB(200, 50, 0))}
  300. local pe = Instance.new("ParticleEmitter",attachment3)
  301. pe.Color = sparks
  302. pe.LightEmission = 0
  303. pe.LightInfluence = 0.125
  304. pe.EmissionDirection = "Front"
  305. pe.Orientation = Enum.ParticleOrientation.VelocityParallel
  306. pe.Size = NumberSequence.new(0.35,0)
  307. pe.Texture = "rbxassetid://243132757"
  308. pe.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0,0),NumberSequenceKeypoint.new(1,0.65)}
  309. pe.Lifetime = NumberRange.new(0.5,1)
  310. pe.Rate = 100
  311. pe.Enabled = false
  312. pe.Rotation = NumberRange.new(90)
  313. pe.RotSpeed = NumberRange.new(0)
  314. pe.Speed = NumberRange.new(40)
  315. pe.SpreadAngle = Vector2.new(-15,15)
  316. pe.Drag = NumberRange.new(0.25)
  317. pe.Acceleration = Vector3.new(0,-65,0)
  318. e = Instance.new("RemoteEvent",part)
  319. e.OnServerEvent:Connect(function(_,info,partt)
  320. if info == "drop" then
  321. sound.PlaybackSpeed = 1
  322. sound.Volume = 0.5
  323. sound.SoundId = "rbxassetid://"..drop
  324. sound.Parent = part
  325. sound.Parent = nil
  326. beam1.Attachment1 = nil
  327. beam2.Attachment1 = nil
  328. beam3.Attachment1 = nil
  329. if align then
  330. align:Destroy()
  331. end
  332. if align2 then
  333. align2:Destroy()
  334. end
  335. s:Stop()
  336. elseif info == "grab" then
  337. s:Play()
  338. sound.PlaybackSpeed = 1
  339. sound.Volume = 1.5
  340. sound.SoundId = "rbxassetid://"..pickup
  341. sound.Parent = part
  342. sound.Parent = nil
  343. if partt:FindFirstAncestorWhichIsA("Model") and partt:FindFirstAncestorWhichIsA("Model").PrimaryPart then
  344. partt = partt:FindFirstAncestorWhichIsA("Model").PrimaryPart
  345. end
  346. local attachment0 = Instance.new("Attachment",partt)
  347. local attachment1 = Instance.new("Attachment",part)
  348. beam1.Attachment1 = attachment2
  349. beam2.Attachment1 = attachment2
  350. beam3.Attachment1 = attachment2
  351. attachment1.CFrame = CFrame.new(0.25,0,-6)
  352. align = Instance.new("AlignPosition",part)
  353. align.Attachment0 = attachment0
  354. align.Attachment1 = attachment1
  355. align.RigidityEnabled = true
  356. align2 = Instance.new("AlignOrientation",part)
  357. align2.Attachment0 = attachment0
  358. align2.Attachment1 = attachment1
  359. align2.RigidityEnabled = true
  360. elseif info == "yeet" then
  361. pe.Brightness = 1
  362. pe.SpreadAngle = Vector2.new(-50,50)
  363. pe.Acceleration = Vector3.new(0,-15,0)
  364. pe.LightEmission = 0.1
  365. pe:Emit(95)
  366. s:Stop()
  367. if align and align.Attachment0 and align.Attachment0.Parent then
  368. tween1:Play()
  369. tween2:Play()
  370. local bv = Instance.new("BodyVelocity",align.Attachment0.Parent)
  371. bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  372. bv.Velocity = part.CFrame.lookVector * 200 + Vector3.new(0,10,0)
  373. align:Destroy()
  374. sound.PlaybackSpeed = 1.125
  375. sound.Volume = 1
  376. sound.SoundId = "rbxassetid://"..launch[math.random(1,4)]
  377. sound.Parent = part
  378. sound.Parent = nil
  379. beam1.Attachment1 = nil
  380. beam2.Attachment1 = nil
  381. beam3.Attachment1 = nil
  382. game:GetService("Debris"):AddItem(bv,0.0625)
  383. if align2 then
  384. align2:Destroy()
  385. end
  386. end
  387. elseif info == "look" then
  388. local lookvector = owner.Character.Torso.CFrame:toObjectSpace(partt).lookVector.unit
  389. weldd.C0 = weldd.C0:Lerp(CFrame.Angles(math.sin(-lookvector.Y)*1,math.sin(lookvector.X)*1,0), 0.2)
  390. headd.C0 = headd.C0:Lerp(CFrame.new(0,-0.5,0) * CFrame.Angles(math.sin(-lookvector.Y)*1,math.sin(lookvector.X)*1,0), 0.2)
  391. weldd3.C0 = weldd3.C0:Lerp(CFrame.Angles(math.sin(-lookvector.Y)*1,math.sin(lookvector.X)*1,0), 0.2)
  392. end
  393. end)
  394. NLS([[
  395. mouse = owner:GetMouse()
  396. count = 0
  397. e = script.Parent
  398. mouse.KeyDown:Connect(function(key)
  399. key = key:lower()
  400. if key == "e" and count == 0 then
  401. local params = OverlapParams.new()
  402. params.FilterDescendantsInstances = {owner.Character:GetDescendants()}
  403. params.FilterType = Enum.RaycastFilterType.Blacklist
  404. for _, v in pairs(workspace:GetPartBoundsInBox(owner.Character.Head.CFrame * CFrame.new(0,0,-20), Vector3.new(0.25,0.25,40), params)) do
  405. if v ~= nil and v.Anchored == false then
  406. count = 1
  407. e:FireServer("grab",v)
  408. break
  409. end
  410. end
  411. elseif key == "e" and count == 1 then
  412. count = 0
  413. e:FireServer("drop")
  414. elseif key == "q" and count == 1 then
  415. e:FireServer("yeet")
  416. count = 0
  417. end
  418. end)
  419. game:GetService("RunService").RenderStepped:Connect(function()
  420. e:FireServer("look",workspace.CurrentCamera.CFrame)
  421. end)
  422. ]],e)
  423. while task.wait() do
  424. if candamage then
  425. local params = OverlapParams.new()
  426. params.FilterDescendantsInstances = {owner.Character:GetDescendants(), script}
  427. params.FilterType = Enum.RaycastFilterType.Blacklist
  428. for _, v in pairs(workspace:GetPartBoundsInBox(partt.CFrame, partt.Size * 1.5, params)) do
  429. if (v:FindFirstAncestorOfClass("Model") and v:FindFirstAncestorOfClass("Model"):FindFirstChildWhichIsA("Humanoid")) and not hitdb then
  430. hitdb = true
  431. v:FindFirstAncestorOfClass("Model"):FindFirstChildWhichIsA("Humanoid").Health -= 15
  432. end
  433. end
  434. end
  435. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement