Guest User

Untitled

a guest
Oct 21st, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. -------- OMG HAX
  2.  
  3. r = game:service("RunService")
  4.  
  5.  
  6. Tool = script.Parent
  7.  
  8. local equalizingForce = 236 / 1.2 -- amount of force required to levitate a mass
  9. local gravity = .75 -- things float at > 1
  10.  
  11. local ghostEffect = nil
  12. local massCon1 = nil
  13. local massCon2 = nil
  14.  
  15.  
  16. local head = nil
  17. function recursiveGetLift(node)
  18. local m = 0
  19. local c = node:GetChildren()
  20. if (node:FindFirstChild("Head") ~= nil) then head = node:FindFirstChild("Head") end -- nasty hack to detect when your parts get blown off
  21.  
  22. for i=1,#c do
  23. if c[i].className == "Part" then
  24. if (head ~= nil and (c[i].Position - head.Position).magnitude < 10) then -- GROSS
  25. if c[i].Name == "Handle" then
  26. m = m + (c[i]:GetMass() * equalizingForce * 1) -- hack that makes hats weightless, so different hats don't change your jump height
  27. else
  28. m = m + (c[i]:GetMass() * equalizingForce * gravity)
  29. end
  30. end
  31. end
  32. m = m + recursiveGetLift(c[i])
  33. end
  34. # I added this
  35. wait(5)
  36. Tool:Destroy()
  37. return m
  38. end
  39.  
  40.  
  41. function onMassChanged(child, char)
  42. print("Mass changed:" .. child.Name .. " " .. char.Name)
  43. if (ghostEffect ~= nil) then
  44. ghostEffect.force = Vector3.new(0, recursiveGetLift(char) ,0)
  45. end
  46. end
  47.  
  48.  
  49.  
  50. function UpdateGhostState(isUnequipping)
  51.  
  52. if isUnequipping == true then
  53. ghostEffect:Remove()
  54. ghostEffect = nil
  55. massCon1:disconnect()
  56. massCon2:disconnect()
  57. else
  58. if ghostEffect == nil then
  59. local char = Tool.Parent
  60. if char == nil then return end
  61. ghostEffect = Instance.new("BodyForce")
  62. ghostEffect.Name = "GravityCoilEffect"
  63. ghostEffect.force = Vector3.new(0, recursiveGetLift(char) ,0)
  64. ghostEffect.Parent = char.Head
  65. ghostChar = char
  66. massCon1 = char.ChildAdded:connect(function(child) onMassChanged(child, char) end)
  67. massCon2 = char.ChildRemoved:connect(function(child) onMassChanged(child, char) end)
  68. end
  69. end
  70.  
  71.  
  72. end
  73.  
  74.  
  75.  
  76. function onEquipped()
  77. Tool.Handle.CoilSound:Play()
  78. UpdateGhostState(false)
  79. end
  80.  
  81. function onUnequipped()
  82. UpdateGhostState(true)
  83. end
  84.  
  85.  
  86. script.Parent.Equipped:connect(onEquipped)
  87. script.Parent.Unequipped:connect(onUnequipped)
Advertisement
Add Comment
Please, Sign In to add comment