Advertisement
Guest User

public script extra - gravity gun

a guest
Jul 13th, 2019
7,230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. --gravity gun by pdnghiaqoi [ marseio ]
  2. --yea
  3. print("gravity gun by pdn [ marseio ]\nleft click to hold\nright click to 'shoot'\nq or scrolldown to pull\ne or scrollup to push\nx to reset distance\nr to remove\nz to anchor/unanchor")
  4. Tool0 = Instance.new("Tool")
  5. Part1 = Instance.new("Part")
  6. SpecialMesh2 = Instance.new("SpecialMesh")
  7. RemoteEvent3 = Instance.new("RemoteEvent")
  8. Tool0.Name = "gravity gun"
  9. Tool0.Parent = owner.Backpack
  10. Tool0.CanBeDropped = false
  11. Tool0.Grip = CFrame.new(-0.18029955, -0.61471349, -1.84482515, -0.992100835, 0.0260190926, -0.122715019, 0.0329591148, 0.9979496, -0.0548671409, 0.121035822, -0.0584783144, -0.99092412)
  12. Tool0.GripForward = Vector3.new(0.122715019, 0.0548671409, 0.99092412)
  13. Tool0.GripPos = Vector3.new(-0.18029955, -0.61471349, -1.84482515)
  14. Tool0.GripRight = Vector3.new(-0.992100835, 0.0329591148, 0.121035822)
  15. Tool0.GripUp = Vector3.new(0.0260190926, 0.9979496, -0.0584783144)
  16. Part1.Name = "Handle"
  17. Part1.Parent = Tool0
  18. Part1.CFrame = CFrame.new(-0.340002, 0.686533988, 0.700002015, -1, 4.80000017e-05, 0, 4.80000017e-05, 1, 0, 0, 0, -1)
  19. Part1.Orientation = Vector3.new(0, 180, 0)
  20. Part1.Position = Vector3.new(-0.340002, 0.686533988, 0.700002015)
  21. Part1.Rotation = Vector3.new(-180, 0, -180)
  22. Part1.Color = Color3.new(0.0156863, 0.686275, 0.92549)
  23. Part1.Size = Vector3.new(1, 0.400000036, 0.300000012)
  24. Part1.BottomSurface = Enum.SurfaceType.Smooth
  25. Part1.BrickColor = BrickColor.new("Cyan")
  26. Part1.CanCollide = false
  27. Part1.Material = Enum.Material.Neon
  28. Part1.TopSurface = Enum.SurfaceType.Smooth
  29. Part1.brickColor = BrickColor.new("Cyan")
  30. Part1.FormFactor = Enum.FormFactor.Custom
  31. Part1.formFactor = Enum.FormFactor.Custom
  32. SpecialMesh2.Parent = Part1
  33. SpecialMesh2.MeshId = "rbxassetid://429945742"
  34. SpecialMesh2.Scale = Vector3.new(0.150000006, 0.150000006, 0.150000006)
  35. SpecialMesh2.TextureId = "rbxassetid://437276827"
  36. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  37. RemoteEvent3.Name = "Remote"
  38. RemoteEvent3.Parent = Tool0
  39.  
  40. wait()
  41. tool = Tool0
  42. object = nil
  43. mousedown = false
  44. found = false
  45. BP = Instance.new("BodyPosition")
  46. BP.maxForce = Vector3.new(math.huge*math.huge,math.huge*math.huge,math.huge*math.huge) --pwns everyone elses bodyposition
  47. BP.P = BP.P*10 --faster movement. less bounceback.
  48. dist = 0
  49. point = Instance.new("Part")
  50. point.Locked = true
  51. point.Anchored = true
  52. point.formFactor = 0
  53. point.Shape = 0
  54. point.Material = 'Neon'
  55. point.BrickColor = BrickColor.new("Toothpaste")
  56. point.Size = Vector3.new(1,1,1)
  57. point.CanCollide = false
  58. local mesh = Instance.new("SpecialMesh")
  59. mesh.MeshType = "Sphere"
  60. mesh.Scale = Vector3.new(.2,.2,.2)
  61. mesh.Parent = point
  62. handle = Part1
  63. front = Part1
  64. color = Part1
  65. local hooked = false
  66. local hookBP = BP:clone()
  67. hookBP.maxForce = Vector3.new(30000,30000,30000)
  68. local remote = RemoteEvent3
  69. local hit = nil
  70. local distp = nil
  71. function onButton1Up()
  72. mousedown = false
  73. end
  74.  
  75. function onButton2Down(lv)
  76. speed = 250
  77. spawn(function()
  78. if object and mousedown and object.Anchored == false then
  79. local fpoint = handle.CFrame.p + handle.CFrame:vectorToWorldSpace(Vector3.new(0, 0.4, -1.1))
  80. local thcf = CFrame.new(fpoint, lv)
  81. object.CFrame = thcf + (thcf.lookVector * (object.Size.Z / 2))
  82. local bv = Instance.new("BodyVelocity")
  83. bv.Velocity = thcf.lookVector * speed
  84. bv.Parent = object
  85. local a = object.Touched:Connect(function(v)
  86. if v.Parent:FindFirstChildOfClass("Humanoid") and v.Parent ~= owner.Character and not game:GetService("Players"):GetPlayerFromCharacter(v.Parent) then
  87. v.Parent:FindFirstChildOfClass("Humanoid").Health = 0
  88. end
  89. end)
  90. object = nil
  91. wait(0.75)
  92. a:Disconnect()
  93. bv:Destroy()
  94. end
  95. end)
  96. end
  97. function onScroll(typ)
  98. if typ == "Forward" then
  99. dist = dist+5
  100. end
  101. if typ == "Backward" then
  102. if (dist>=5) then
  103. dist = dist-5
  104. end
  105. end
  106. end
  107.  
  108. function onButton1Down(target)
  109. if (mousedown==true) then return end
  110. mousedown = true
  111. coroutine.resume(coroutine.create(function()
  112. local p = point:clone()
  113. p.Parent = tool
  114. while (mousedown==true) do
  115. p.Parent = tool
  116. if (object==nil) then
  117. if (target==nil) then
  118. local lv = CFrame.new(front.Position,hit)
  119. p.CFrame = CFrame.new(front.Position+(lv.lookVector*1000))
  120. else
  121. p.CFrame = CFrame.new(hit)
  122. end
  123. else
  124. break
  125. end
  126. wait()
  127. end
  128. p:remove()
  129. end))
  130. while (mousedown==true) do
  131. if (target~=nil) then
  132. local t = target
  133. if (t.Parent) then
  134. object = t
  135. if object.Anchored==false then
  136. dist = (object.Position-front.Position).magnitude
  137. distp = object.Position-front.Position
  138. end
  139. break
  140. end
  141. end
  142. wait()
  143. end
  144. while (mousedown==true) do
  145. if (object and object.Parent==nil) then break end
  146. local lv = CFrame.new(front.Position,hit)
  147. BP.Parent = object
  148. BP.position = front.Position+lv.lookVector*dist
  149. wait()
  150. end
  151. BP:remove()
  152. object = nil
  153. end
  154. function onKeyDown(key)
  155. local key = key:lower()
  156. local yesh = false
  157. if key == "" then
  158. if (object==nil) then return end
  159. for _,v in pairs(object:children()) do
  160. if v.className == "BodyGyro" then
  161. return nil
  162. end
  163. end
  164. BG = Instance.new("BodyGyro")
  165. BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  166. BG.cframe = CFrame.new(object.CFrame.p)
  167. BG.Parent = object
  168. repeat wait() until(object.CFrame == CFrame.new(object.CFrame.p))
  169. BG.Parent = nil
  170. if (object==nil) then return end
  171. for _,v in pairs(object:children()) do
  172. if v.className == "BodyGyro" then
  173. v.Parent = nil
  174. end
  175. end
  176. object.Velocity = Vector3.new(0,0,0)
  177. object.RotVelocity = Vector3.new(0,0,0)
  178. end
  179. if (string.byte(key)==27) then
  180. if (object==nil) then return end
  181. local e = Instance.new("Explosion")
  182. e.Parent = workspace
  183. e.Position = object.Position
  184. color.BrickColor = BrickColor.Black()
  185. point.BrickColor = BrickColor.White()
  186. wait(.48)
  187. color.BrickColor = BrickColor.White()
  188. point.BrickColor = BrickColor.Black()
  189. end
  190. if (key=="") then
  191. if not hooked then
  192. if (object==nil) then return end
  193. hooked = true
  194. hookBP.position = object.Position
  195. if tool.Parent:findFirstChild("HumanoidRootPart") then
  196. hookBP.Parent = tool.Parent.HumanoidRootPart
  197. if dist ~= (object.Size.x+object.Size.y+object.Size.z)+5 then
  198. dist = (object.Size.x+object.Size.y+object.Size.z)+5
  199. distp = object.Size
  200. end
  201. end
  202. else
  203. hooked = false
  204. hookBP.Parent = nil
  205. end
  206. end
  207. if (key=="r") then
  208. if (object==nil) then return end
  209. color.BrickColor = BrickColor.new("Toothpaste")
  210. point.BrickColor = BrickColor.new("Toothpaste")
  211. object.Parent = nil
  212. wait(.48)
  213. color.BrickColor = BrickColor.new("Toothpaste")
  214. point.BrickColor = BrickColor.new("Toothpaste")
  215. end
  216. if (key=="q") then
  217. onScroll("Backward")
  218. end
  219. if (key=="e") then
  220. onScroll("Forward")
  221. end
  222. if (key=="x") then
  223. dist = 5
  224. end
  225. if (key=="z") then
  226. if (object==nil) then return end
  227. if not (object:IsA("MeshPart") or object:IsA("Part") or object:IsA("Union") or object:IsA("BasePart")) then return end
  228. if object.Anchored == true then object.Anchored = false
  229. elseif object.Anchored == false then object.Anchored = true end
  230. end
  231. if (key=="") then
  232. if (object==nil) then return end
  233. local New = object:clone()
  234. New.Parent = object.Parent
  235. for _,v in pairs(New:children()) do
  236. if v.className == "BodyPosition" or v.className == "BodyGyro" then
  237. v.Parent = nil
  238. end
  239. end
  240. object = New
  241. mousedown = false
  242. mousedown = true
  243. while (mousedown==true) do
  244. if (object.Parent==nil) then break end
  245. local lv = CFrame.new(front.Position,hit)
  246. BP.Parent = object
  247. BP.position = front.Position+lv.lookVector*dist
  248. wait()
  249. end
  250. BP:remove()
  251. object = nil
  252. end
  253. if (key=="") then
  254. local Cube = Instance.new("Part")
  255. Cube.Locked = true
  256. Cube.Size = Vector3.new(4,4,4)
  257. Cube.formFactor = 0
  258. Cube.TopSurface = 0
  259. Cube.BottomSurface = 0
  260. Cube.Name = "WeightedStorageCube"
  261. Cube.Parent = workspace
  262. Cube.CFrame = CFrame.new(hit) + Vector3.new(0,2,0)
  263. for i = 0,5 do
  264. local Decal = Instance.new("Decal")
  265. Decal.Texture = "http://www.roblox.com/asset/?id=2662260"
  266. Decal.Face = i
  267. Decal.Name = "WeightedStorageCubeDecal"
  268. Decal.Parent = Cube
  269. end
  270. end
  271. if (key=="") then
  272. if dist ~= 15 then
  273. dist = 15
  274. end
  275. end
  276. end
  277.  
  278. remote.OnServerEvent:Connect(function(player, thing, key, target)
  279. if thing == "MouseUp" then
  280. onButton1Up()
  281. elseif thing == "MouseDown" then
  282. onButton1Down(target)
  283. elseif thing == "Mouse2Down" then
  284. onButton2Down(key)
  285. elseif thing == "KeyDown" then
  286. onKeyDown(key)
  287. elseif thing == "ChangePosition" then
  288. hit = key
  289. elseif thing == "ScrollUp" then
  290. onScroll("Forward")
  291. elseif thing == "ScrollDown" then
  292. onScroll("Backward")
  293. end
  294. end)
  295. NLS([==[
  296. wait()
  297. local remote = script.Parent:WaitForChild("Remote")
  298. local m = game:GetService("Players").LocalPlayer:GetMouse()
  299.  
  300. function ret(mouse)
  301. local from = workspace.CurrentCamera.CoordinateFrame.p
  302. local to = mouse.Hit.p
  303. local ignore = workspace:GetChildren()
  304. local ray = Ray.new( from, (to - from).unit * 1000)
  305. local target, hit = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
  306. return hit
  307. end
  308.  
  309. spawn(function()
  310. while wait() do
  311. if m and m.Hit.p then
  312. remote:FireServer("ChangePosition", m.Hit.p, nil)
  313. end
  314. end
  315. end)
  316. tool = script.Parent
  317.  
  318. function onEquipped(mouse)
  319. mouse.Button1Down:connect(function()
  320. remote:FireServer("MouseDown", nil, mouse.Target or nil)
  321. mouse.TargetFilter = mouse.Target.Parent
  322. end)
  323. mouse.Button2Down:connect(function()
  324. remote:FireServer("Mouse2Down", ret(mouse), mouse.Target or nil)
  325. end)
  326. mouse.Button1Up:connect(function()
  327. remote:FireServer("MouseUp", nil, mouse.Target or nil)
  328. mouse.TargetFilter = nil
  329. end)
  330. mouse.KeyDown:connect(function(key)
  331. remote:FireServer("KeyDown", key, mouse.Target or nil)
  332. end)
  333. mouse.WheelForward:Connect(function()
  334. remote:FireServer("ScrollUp", nil, nil)
  335. end)
  336. mouse.WheelBackward:Connect(function()
  337. remote:FireServer("ScrollDown", nil, nil)
  338. end)
  339. end
  340.  
  341. tool.Equipped:connect(onEquipped)
  342. ]==],Tool0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement