KFCINTHEMORNING

Untitled

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