Advertisement
HowAreYu

turning into loadstring

Jul 26th, 2020 (edited)
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. --[[
  2. Original creator might be: not sure
  3. Edit by: dak#1111
  4.  
  5. Made it less aids to read + some quality of life changes. :p
  6. (Who ever made this, for the love of god learn to not make spaghetti.)
  7. --]]
  8.  
  9. -- Variables and setting up the character
  10. local rs = game:GetService("RunService")
  11.  
  12. local plr = game:GetService("Players").LocalPlayer
  13. local char = plr.Character
  14. char.Archivable = true
  15. local cam = workspace:WaitForChild("Camera")
  16.  
  17. local fakechar = char:Clone()
  18. fakechar.Head.face.Texture = ""
  19. fakechar.Parent = workspace
  20. cam.CameraSubject = fakechar:FindFirstChildOfClass("Humanoid")
  21.  
  22. local connections = {}
  23. local kill = false
  24.  
  25. -- Align function
  26. local function Align(Part1, Part0, Position, Angle)
  27. Part1.CanCollide = true
  28.  
  29. local AlignPos = Instance.new("AlignPosition")
  30. AlignPos.ApplyAtCenterOfMass = true
  31. AlignPos.MaxForce = 100000
  32. AlignPos.MaxVelocity = math.huge
  33. AlignPos.ReactionForceEnabled = false
  34. AlignPos.Responsiveness = 200
  35. AlignPos.RigidityEnabled = false
  36. AlignPos.Parent = Part1
  37.  
  38. local AlignOri = Instance.new("AlignOrientation")
  39. AlignOri.MaxAngularVelocity = math.huge
  40. AlignOri.MaxTorque = 100000
  41. AlignOri.PrimaryAxisOnly = false
  42. AlignOri.ReactionTorqueEnabled = false
  43. AlignOri.Responsiveness = 200
  44. AlignOri.RigidityEnabled = false
  45. AlignOri.Parent = Part1
  46.  
  47. local at1 = Instance.new("Attachment")
  48. at1.Parent = Part1
  49. local at2 = Instance.new("Attachment")
  50. at2.Parent = Part0
  51. at2.Orientation = Angle
  52. at2.Position = Position
  53.  
  54. AlignPos.Attachment0 = at1
  55. AlignPos.Attachment1 = at2
  56. AlignOri.Attachment0 = at1
  57. AlignOri.Attachment1 = at2
  58. end
  59.  
  60. local success, fail = pcall(function()
  61. -- Make the fake character invisible
  62. for _,v in pairs(fakechar:GetDescendants()) do
  63. if v:IsA("Part") then
  64. v.Transparency = 1
  65. elseif v:IsA("SpecialMesh") then
  66. v.MeshId = "rbxassetid://0"
  67. end
  68. end
  69. -- Noclipping
  70. table.insert(connections, rs.Stepped:Connect(function()
  71. fakechar:FindFirstChild("Head").CanCollide = true
  72. fakechar:FindFirstChild("Torso").CanCollide = true
  73. char.Head.CanCollide = false
  74. char.Torso.CanCollide = false
  75. end))
  76. table.insert(connections, rs.Heartbeat:Connect(function()
  77. fakechar:FindFirstChild("Head").CanCollide = true
  78. fakechar:FindFirstChild("Torso").CanCollide = true
  79. char.Head.CanCollide = false
  80. char.Torso.CanCollide = false
  81. end))
  82. table.insert(connections, rs.RenderStepped:Connect(function()
  83. fakechar:FindFirstChild("Head").CanCollide = true
  84. fakechar:FindFirstChild("Torso").CanCollide = true
  85. char.Head.CanCollide = false
  86. char.Torso.CanCollide = false
  87. end))
  88.  
  89. -- Rigging
  90. char.Torso["Right Shoulder"]:Destroy()
  91. char.Torso["Left Shoulder"]:Destroy()
  92. char.Torso["Right Hip"]:Destroy()
  93. char.Torso["Left Hip"]:Destroy()
  94. char.HumanoidRootPart["RootJoint"]:Destroy()
  95. char.HumanoidRootPart.Anchored = true
  96. char.Humanoid.PlatformStand = true
  97. fakechar["Torso"].Position = char["Torso"].Position
  98.  
  99. -- Align
  100. for _,v in pairs(char:GetChildren()) do
  101. if v:IsA("Part") and v.Name ~= "Head" then
  102. if v.Name == "Torso" then
  103. Align(char[v.Name], fakechar[v.Name], Vector3.new(0,0.5,0),Vector3.new(0,0,0))
  104. else
  105. Align(char[v.Name], fakechar[v.Name], Vector3.new(0,0,0),Vector3.new(0,0,0))
  106. end
  107. end
  108. end
  109. end)
  110. if fail then
  111. warn(fail)
  112. plr.Character = char
  113. char:BreakJoints()
  114. fakechar:Destroy()
  115.  
  116. kill = true
  117. return
  118. end
  119.  
  120. -- Cleanup
  121. fakechar.Humanoid.Died:Connect(function()
  122. plr.Character = char
  123. char:BreakJoints()
  124. fakechar:Destroy()
  125.  
  126. kill = true
  127.  
  128. for _,v in pairs(connections) do v:Disconnect() end
  129. end)
  130. char.Humanoid.Died:Connect(function()
  131. plr.Character = char
  132. char:BreakJoints()
  133. fakechar:Destroy()
  134.  
  135. kill = true
  136.  
  137. for _,v in pairs(connections) do v:Disconnect() end
  138. end)
  139.  
  140. plr.Character = fakechar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement