ProfessorPuddle

Roblox MM2 Script - Invisibitity

Dec 20th, 2020
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. local Player = game:GetService("Players").LocalPlayer
  2. repeat wait(.1) until Player.Character
  3. local Character = Player.Character
  4. Character.Archivable = true
  5. local IsInvis = false
  6. local IsRunning = true
  7. local InvisibleCharacter = Character:Clone()
  8. InvisibleCharacter.Parent = game:GetService'Lighting'
  9. local Void = workspace.FallenPartsDestroyHeight
  10. InvisibleCharacter.Name = ""
  11. local CF
  12.  
  13. Player.CharacterAdded:Connect(function()
  14. if Player.Character == InvisibleCharacter then return end
  15. repeat wait(.1) until Player.Character:FindFirstChildWhichIsA'Humanoid'
  16. if IsRunning == false then
  17. IsInvis = false
  18. IsRunning = true
  19. Character = Player.Character
  20. Character.Archivable = true
  21. InvisibleCharacter = Character:Clone()
  22. InvisibleCharacter.Name = ""
  23. InvisibleCharacter:FindFirstChildOfClass'Humanoid'.Died:Connect(function()
  24. Respawn()
  25. end)
  26. for i,v in pairs(InvisibleCharacter:GetDescendants())do
  27. if v:IsA("BasePart") then
  28. if v.Name == "HumanoidRootPart" then
  29. v.Transparency = 1
  30. else
  31. v.Transparency = .5
  32. end
  33. end
  34. end
  35. end
  36. end)
  37.  
  38. local Fix = game:GetService("RunService").Stepped:Connect(function()
  39. pcall(function()
  40. local IsInteger
  41. if tostring(Void):find'-' then
  42. IsInteger = true
  43. else
  44. IsInteger = false
  45. end
  46. local Pos = Player.Character.HumanoidRootPart.Position
  47. local Pos_String = tostring(Pos)
  48. local Pos_Seperate = Pos_String:split(', ')
  49. local X = tonumber(Pos_Seperate[1])
  50. local Y = tonumber(Pos_Seperate[2])
  51. local Z = tonumber(Pos_Seperate[3])
  52. if IsInteger == true then
  53. if Y <= Void then
  54. Respawn()
  55. end
  56. elseif IsInteger == false then
  57. if Y >= Void then
  58. Respawn()
  59. end
  60. end
  61. end)
  62. end)
  63.  
  64. for i,v in pairs(InvisibleCharacter:GetDescendants())do
  65. if v:IsA("BasePart") then
  66. if v.Name == "HumanoidRootPart" then
  67. v.Transparency = 1
  68. else
  69. v.Transparency = .5
  70. end
  71. end
  72. end
  73.  
  74. Player.Chatted:Connect(function(c)
  75. if c:lower() == '/e invis' or c:lower() == ';invis' then
  76. TurnInvisible()
  77. end
  78. if c:lower() == '/e vis' or c:lower() == ';vis' then
  79. TurnVisible()
  80. end
  81. end)
  82.  
  83. function Respawn()
  84. IsRunning = false
  85. if IsInvis == true then
  86. pcall(function()
  87. Player.Character = Character
  88. wait()
  89. Character.Parent = workspace
  90. Character:FindFirstChildWhichIsA'Humanoid':Destroy()
  91. IsInvis = false
  92. InvisibleCharacter.Parent = nil
  93. end)
  94. elseif IsInvis == false then
  95. pcall(function()
  96. Player.Character = Character
  97. wait()
  98. Character.Parent = workspace
  99. Character:FindFirstChildWhichIsA'Humanoid':Destroy()
  100. IsInvis = false
  101. end)
  102. end
  103. end
  104.  
  105. InvisibleCharacter:FindFirstChildOfClass'Humanoid'.Died:Connect(function()
  106. Respawn()
  107. end)
  108.  
  109. function FixCam()
  110. workspace.CurrentCamera.CameraSubject = Player.Character:FindFirstChildWhichIsA'Humanoid'
  111. workspace.CurrentCamera.CFrame = CF
  112. end
  113.  
  114. function freezecam(arg)
  115. if arg == true then
  116. workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
  117. else
  118. workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
  119. end
  120. end
  121.  
  122. function TurnInvisible()
  123. if IsInvis == true then return end
  124. IsInvis = true
  125. CF = workspace.CurrentCamera.CFrame
  126. local CF_1 = Player.Character.HumanoidRootPart.CFrame
  127. Character:MoveTo(Vector3.new(0,math.pi*1000000,0))
  128. freezecam(true)
  129. wait(.2)
  130. freezecam(false)
  131. InvisibleCharacter = InvisibleCharacter
  132. Character.Parent = game:GetService'Lighting'
  133. InvisibleCharacter.Parent = workspace
  134. InvisibleCharacter.HumanoidRootPart.CFrame = CF_1
  135. Player.Character = InvisibleCharacter
  136. FixCam()
  137. Player.Character.Animate.Disabled = true
  138. Player.Character.Animate.Disabled = false
  139. end
  140.  
  141. function FixScript()
  142. --[[Character = nil
  143. InvisibleCharacter = nil
  144. if IsInvis == true then
  145. repeat wait() until IsInvis == false
  146. end
  147. if not Player.Character.Head:FindFirstChildWhichIsA("Motor6D") then
  148. repeat wait() warn('Bruh you\'re dead lol') until Player.Character.Head:FindFirstChildWhichIsA("Motor6D")
  149. local LCharacter = Player.Character
  150. LCharacter.Archivable = true
  151. local LnvisibleCharacter = LCharacter:Clone()
  152. InvisibleCharacter = LnvisibleCharacter
  153. InvisibleCharacter.Parent = game:GetService'Lighting'
  154. for i,v in pairs(InvisibleCharacter:GetDescendants())do
  155. if v:IsA("BasePart") then
  156. v.Transparency = .5
  157. end
  158. end
  159. end
  160. IsRunning = true]]
  161. end
  162.  
  163. function TurnVisible()
  164. if IsInvis == false then return end
  165. CF = workspace.CurrentCamera.CFrame
  166. Character = Character
  167. local CF_1 = Player.Character.HumanoidRootPart.CFrame
  168. Character.HumanoidRootPart.CFrame = CF_1
  169. InvisibleCharacter.Parent = game:GetService'Lighting'
  170. Player.Character = Character
  171. Character.Parent = workspace
  172. IsInvis = false
  173. FixCam()
  174. Player.Character.Animate.Disabled = true
  175. Player.Character.Animate.Disabled = false
  176. end
Advertisement
Add Comment
Please, Sign In to add comment