mrhotmadm

Amokah's Invisibility Script

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