Advertisement
Guest User

SimpleBodyPosv2

a guest
Mar 25th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. wait(5)
  2. local active = true
  3. local fixpart = Instance.new("Part")
  4. fixpart.Parent = game.Workspace
  5. fixpart.Transparency = 1
  6. local parts = {}
  7. function FUNCTION(a)
  8. if (a.className == "Part") or (a.className == "Seat") or (a.className == "SpawnLocation") or (a.className == "Union") or (a.className == "MeshPart") then
  9. if a.Anchored == false and (a:IsDescendantOf(game.Players.LocalPlayer.Character) == false) then
  10. table.insert(parts, a)
  11. end
  12. end
  13. local b = a:GetChildren()
  14. for i=1,#b do
  15. FUNCTION(b[i])
  16. end
  17. end
  18. FUNCTION(game.workspace)
  19. for i,v in pairs(parts) do
  20. wait(.01)
  21. v.CanCollide = true
  22. local bp = Instance.new("BodyPosition")
  23. bp.P = 0
  24. bp.Parent = v
  25. local att1 = Instance.new("Attachment")
  26. att1.Parent = v
  27. local att2 = Instance.new("Attachment")
  28. att2.Parent = fixpart
  29. local weldfix = Instance.new("RopeConstraint")
  30. weldfix.Length = 0
  31. weldfix.Parent = v
  32. weldfix.Attachment0 = att1
  33. weldfix.Attachment1 = att2
  34. end
  35. game:GetService("RunService").RenderStepped:Connect(function()
  36. fixpart.Position = game.Players.LocalPlayer:GetMouse().Hit.Position
  37. end)
  38. function onKeyPress(actionName, userInputState, inputObject)
  39. if userInputState == Enum.UserInputState.Begin then
  40. if active == true then
  41. active = false
  42. for i,v in pairs(parts) do
  43. v.RopeConstraint.Enabled = false
  44. end
  45. else
  46. active = true
  47. for i,v in pairs(parts) do
  48. v.RopeConstraint.Enabled = true
  49. end
  50. end
  51. end
  52. end
  53.  
  54. game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.X)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement