Advertisement
Godofadmin1337

Gravity hammer

Nov 15th, 2017
1,241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.61 KB | None | 0 0
  1. --Converted with ttyyuu12345's model to script plugin v4
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do
  6. print("FE Compatibility code by Mokiros")
  7. local rp = RealPlayer
  8. script.Parent = rp.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,Functions={},Connect=function(self,f)table.insert(self.Functions,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(),Button2Up=fakeEvent(),Button2Down=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 then
  34. for _,f in pairs(t.Functions) do
  35. f(...)
  36. end
  37. end
  38. end
  39. m.TrigEvent = te
  40. UIS.TrigEvent = te
  41.  
  42. Event.OnServerEvent:Connect(function(plr,io)
  43. if plr~=rp then return end
  44. m.Target = io.Target
  45. m.Hit = io.Hit
  46. if not io.isMouse then
  47. local b = io.UserInputState == Enum.UserInputState.Begin
  48. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  49. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  50. end
  51. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  52. return m:TrigEvent(b and "Button2Down" or "Button2Up")
  53. end
  54. for _,t in pairs(CAS.Actions) do
  55. for _,k in pairs(t.Keys) do
  56. if k==io.KeyCode then
  57. t.Function(t.Name,io.UserInputState,io)
  58. end
  59. end
  60. end
  61. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  62. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  63. end
  64. end)
  65. Event.Parent = NLS([==[
  66. local Player = game:GetService("Players").LocalPlayer
  67. local Event = script:WaitForChild("UserInput_Event")
  68. local Mouse = Player:GetMouse()
  69. local UIS = game:GetService("UserInputService")
  70. local input = function(io,a)
  71. if a then return end
  72. --Since InputObject is a client-side instance, we create and pass table instead
  73. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  74. end
  75. UIS.InputBegan:Connect(input)
  76. UIS.InputEnded:Connect(input)
  77. local h,t
  78. --Give the server mouse data 30 times every second, but only if the values changed
  79. --If player is not moving their mouse, client won't fire events
  80. while wait(1/30) do
  81. if h~=Mouse.Hit or t~=Mouse.Target then
  82. h,t=Mouse.Hit,Mouse.Target
  83. Event:FireServer({isMouse=true,Target=t,Hit=h})
  84. end
  85. end]==],Player.Character)
  86.  
  87. ----Sandboxed game object that allows the usage of client-side methods and services
  88. --Real game object
  89. local _rg = game
  90.  
  91. --Metatable for fake service
  92. local fsmt = {
  93. __index = function(self,k)
  94. local s = rawget(self,"_RealService")
  95. if s then
  96. return typeof(s[k])=="function"
  97. and function(_,...)return s[k](s,...)end or s[k]
  98. end
  99. end,
  100. __newindex = function(self,k,v)
  101. local s = rawget(self,"_RealService")
  102. if s then s[k]=v end
  103. end
  104. }
  105. local function FakeService(t,RealService)
  106. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  107. return setmetatable(t,fsmt)
  108. end
  109.  
  110. --Fake game object
  111. local g = {
  112. GetService = function(self,s)
  113. return rawget(self,s) or _rg:GetService(s)
  114. end,
  115. Players = FakeService({
  116. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  117. },"Players"),
  118. UserInputService = FakeService(UIS,"UserInputService"),
  119. ContextActionService = FakeService(CAS,"ContextActionService"),
  120. RunService = FakeService({
  121. _btrs = {},
  122. RenderStepped = _rg:GetService("RunService").Heartbeat,
  123. BindToRenderStep = function(self,name,_,fun)
  124. self._btrs[name] = self.Heartbeat:Connect(fun)
  125. end,
  126. UnbindFromRenderStep = function(self,name)
  127. self._btrs[name]:Disconnect()
  128. end,
  129. },"RunService")
  130. }
  131. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  132. g.service = g.GetService
  133. FakeService(g,game)
  134. --Changing owner to fake player object to support owner:GetMouse()
  135. game,owner = g,g.Players.LocalPlayer
  136. end
  137.  
  138. function sandbox(var,func)
  139. local env = getfenv(func)
  140. local newenv = setmetatable({},{
  141. __index = function(self,k)
  142. if k=="script" then
  143. return var
  144. else
  145. return env[k]
  146. end
  147. end,
  148. })
  149. setfenv(func,newenv)
  150. return func
  151. end
  152. cors = {}
  153. mas = Instance.new("Model",game:GetService("Lighting"))
  154. Tool0 = Instance.new("Tool")
  155. Part1 = Instance.new("Part")
  156. SpecialMesh2 = Instance.new("SpecialMesh")
  157. Sound3 = Instance.new("Sound")
  158. Sound4 = Instance.new("Sound")
  159. Sound5 = Instance.new("Sound")
  160. LocalScript6 = Instance.new("LocalScript")
  161. Animation7 = Instance.new("Animation")
  162. Animation8 = Instance.new("Animation")
  163. Tool0.Name = "GravityHammer"
  164. Tool0.Parent = mas
  165. Tool0.TextureId = "http://www.roblox.com/asset/?id=33685977"
  166. Tool0.GripPos = Vector3.new(0, -1.20000005, 0.600000024)
  167. Part1.Name = "Handle"
  168. Part1.Parent = Tool0
  169. Part1.BrickColor = BrickColor.new("Bright blue")
  170. Part1.Rotation = Vector3.new(-180, -45.2199974, -90)
  171. Part1.RotVelocity = Vector3.new(-0.00272385264, -2.54290589e-09, -0.00430084066)
  172. Part1.Velocity = Vector3.new(-0.000151261294, -0.00117295235, 0.00204674504)
  173. Part1.Locked = true
  174. Part1.FormFactor = Enum.FormFactor.Symmetric
  175. Part1.Size = Vector3.new(2, 5, 3)
  176. Part1.CFrame = CFrame.new(-4.19833183, 1.38980305, -58.2337456, -5.96046448e-07, 0.704422891, -0.709780633, 1.00000012, 8.34465027e-07, 1.78813934e-07, 7.74860382e-07, -0.709780633, -0.704422951)
  177. Part1.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  178. Part1.Position = Vector3.new(-4.19833183, 1.38980305, -58.2337456)
  179. Part1.Orientation = Vector3.new(0, -134.779999, 90)
  180. Part1.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  181. SpecialMesh2.Parent = Part1
  182. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=33685862"
  183. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=33685897"
  184. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  185. Sound3.Name = "Hit"
  186. Sound3.Parent = Part1
  187. Sound3.SoundId = "http://www.roblox.com/asset/?id=30172281"
  188. Sound4.Name = "SendOut"
  189. Sound4.Parent = Part1
  190. Sound4.SoundId = "http://www.roblox.com/asset/?id=30172373"
  191. Sound5.Name = "InitialHit"
  192. Sound5.Parent = Part1
  193. Sound5.SoundId = "http://www.roblox.com/asset/?id=30299564"
  194. LocalScript6.Name = "GravityHammerScript"
  195. LocalScript6.Parent = Tool0
  196. table.insert(cors,sandbox(LocalScript6,function()
  197. local Tool = script.Parent
  198. local hit = nil
  199. local out = nil
  200. local humanoid = nil
  201. local torso = nil
  202. local enabled = false
  203. local connection = nil
  204. local reload = 5
  205. local hammerStrength = 30
  206. local upStrength = 1500
  207. local children = {}
  208. local toAffect = {}
  209.  
  210. local debris = game:GetService("Debris")
  211.  
  212. function onActivated()
  213.  
  214. if enabled then
  215. return
  216. end
  217.  
  218. enabled = true
  219.  
  220. if hit ~= nil then
  221.  
  222. makeHammerActive()
  223. hit:Play(0.1,1,1)
  224. connection = hit.KeyframeReached:connect(sendFlying)
  225.  
  226. wait(reload)
  227. end
  228.  
  229. enabled = false
  230.  
  231. end
  232.  
  233. function makeHammerActive()
  234.  
  235. local part = Instance.new("Part")
  236. part.Transparency = 1
  237. part.formFactor = 2
  238. part.Size = Vector3.new(1,0.4,1)
  239.  
  240. local fire = Instance.new("Fire")
  241. fire.Color = Color3.new(155/255,1,206/255)
  242. fire.SecondaryColor = Color3.new(0,1,1)
  243. fire.Heat = -5
  244. fire.Size = 8
  245. fire.Parent = part
  246.  
  247. part.Parent = game.Workspace
  248.  
  249. local weld = Instance.new("Weld")
  250. weld.Part0 = part
  251. weld.Parent = part
  252. weld.Part1 = Tool.Handle
  253. weld.C0 = CFrame.new(0,-4.5,0)
  254.  
  255. debris:AddItem(part,1.5)
  256.  
  257. end
  258.  
  259. function sendFlying(stringframe)
  260.  
  261. if stringframe == "sendflying" then
  262.  
  263. connection:disconnect()
  264.  
  265. Tool.Handle.InitialHit:Play()
  266. Tool.Handle.Hit:Play()
  267.  
  268. children = {}
  269. recursiveGetChildren(game.Workspace)
  270.  
  271. for i = 1, #children do
  272. if children[i].Anchored == false then
  273.  
  274. local dist = Vector3.new(children[i].Position.x - torso.Position.x,children[i].Position.y - torso.Position.y,children[i].Position.z - torso.Position.z)
  275. if dist.magnitude <= hammerStrength then
  276.  
  277. local bodyPos = Instance.new("BodyPosition")
  278. local height = hammerStrength * (1 - (dist.magnitude/hammerStrength))
  279. bodyPos.position = children[i].Position + Vector3.new(0,height,0)
  280. bodyPos.P = children[i]:GetMass() * upStrength
  281. bodyPos.D = bodyPos.P/2
  282. bodyPos.maxForce = Vector3.new(bodyPos.P,bodyPos.P,bodyPos.P)
  283. bodyPos.Parent = children[i]
  284. debris:AddItem(bodyPos,3)
  285.  
  286. if children[i].Parent:FindFirstChild("Humanoid") == nil and children[i].Parent.Parent:FindFirstChild("Humanoid") == nil then
  287. children[i]:BreakJoints()
  288. end
  289.  
  290. table.insert(toAffect,children[i])
  291.  
  292. end
  293.  
  294. end
  295. end
  296.  
  297.  
  298. end
  299.  
  300. wait(3.1)
  301. sendOut()
  302. toAffect = {}
  303.  
  304. end
  305.  
  306. function sendForceFieldOut()
  307.  
  308. local fire = Instance.new("Fire")
  309. fire.Color = Color3.new(155/255,1,206/255)
  310. fire.SecondaryColor = Color3.new(0,1,1)
  311. fire.Heat = -5
  312. fire.Size = 1
  313. fire.Parent = torso
  314. for i = 1, 8 do
  315. fire.Size = fire.Size + 4
  316. wait(0.2)
  317. end
  318. fire:remove()
  319. end
  320.  
  321. function sendOut()
  322.  
  323.  
  324. if #toAffect > 0 then
  325.  
  326. Tool.Handle.SendOut:Play()
  327.  
  328. local co = coroutine.create(sendForceFieldOut)
  329. coroutine.resume(co)
  330.  
  331. out:Play()
  332. out.KeyframeReached:connect(function(string)
  333. if string == "end" then
  334. wait(0.4)
  335. out:Stop()
  336. end
  337. end)
  338.  
  339. end
  340.  
  341. wait(0.3)
  342.  
  343. for i =1, #toAffect do
  344.  
  345. if toAffect[i].Parent ~= nil and toAffect[i].Parent ~= torso.Parent then
  346.  
  347. local dist = Vector3.new(torso.Position.x - toAffect[i].Position.x,torso.Position.y - toAffect[i].Position.y,torso.Position.z - toAffect[i].Position.z)
  348.  
  349. local bodyForce = Instance.new("BodyForce")
  350. bodyForce.force = dist.unit * toAffect[i]:GetMass() * -400
  351. bodyForce.Parent = toAffect[i]
  352.  
  353. if toAffect[i].Parent:FindFirstChild("Humanoid") ~= nil and toAffect[i].Name == "Torso" then
  354. toAffect[i].Parent:FindFirstChild("Humanoid").Sit = true
  355. end
  356.  
  357. debris:AddItem(bodyForce,1)
  358.  
  359. end
  360.  
  361. end
  362.  
  363. end
  364.  
  365. function recursiveGetChildren(parent)
  366.  
  367. local kids = parent:GetChildren()
  368.  
  369. if kids ~= nil then
  370. for i =1, #kids do
  371.  
  372. if kids[i].className == "Part" then
  373. table.insert(children,kids[i])
  374. end
  375. recursiveGetChildren(kids[i])
  376.  
  377. end
  378. end
  379.  
  380. end
  381.  
  382. function onEquipped()
  383.  
  384. humanoid = Tool.Parent:FindFirstChild("Humanoid")
  385. torso = Tool.Parent:FindFirstChild("Torso")
  386. hit = humanoid:LoadAnimation(Tool.gravityslam)
  387. out = humanoid:LoadAnimation(Tool.staffout)
  388.  
  389. end
  390.  
  391. function onUnequipped()
  392.  
  393. hit:Stop()
  394. hit:remove()
  395. out:Stop()
  396. out:remove()
  397. end
  398.  
  399. Tool.Equipped:connect(onEquipped)
  400. Tool.Unequipped:connect(onUnequipped)
  401. Tool.Activated:connect(onActivated)
  402. end))
  403. Animation7.Name = "gravityslam"
  404. Animation7.Parent = Tool0
  405. Animation7.AnimationId = "http://www.roblox.com/Asset?ID=33169573"
  406. Animation8.Name = "staffout"
  407. Animation8.Parent = Tool0
  408. Animation8.AnimationId = "http://www.roblox.com/Asset?ID=27432686"
  409. for i,v in pairs(mas:GetChildren()) do
  410. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  411. pcall(function() v:MakeJoints() end)
  412. end
  413. mas:Destroy()
  414. for i,v in pairs(cors) do
  415. spawn(function()
  416. pcall(v)
  417. end)
  418. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement