Advertisement
BEAM21

Invis script

Jan 25th, 2023
1,542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.04 KB | None | 0 0
  1. local ScriptStarted = false
  2. local Keybind = "z" --Set to whatever you want, has to be the name of a KeyCode Enum.
  3. local Transparency = true --Will make you slightly transparent when you are invisible. No reason to disable.
  4. local NoClip = false --Will make your fake character no clip.
  5.  
  6. local Player = game:GetService("Players").LocalPlayer
  7. local RealCharacter = Player.Character or Player.CharacterAdded:Wait()
  8.  
  9. local IsInvisible = false
  10.  
  11. RealCharacter.Archivable = true
  12. local FakeCharacter = RealCharacter:Clone()
  13. local Part
  14. Part = Instance.new("Part", workspace)
  15. Part.Anchored = true
  16. Part.Size = Vector3.new(200, 1, 200)
  17. Part.CFrame = CFrame.new(99999999999999999999999999999, 900, 99999999999999999999) --Set this to whatever you want, just far away from the map.
  18. Part.CanCollide = true
  19. FakeCharacter.Parent = workspace
  20. FakeCharacter.HumanoidRootPart.CFrame = Part.CFrame * CFrame.new(0, 5, 0)
  21.  
  22. for i, v in pairs(RealCharacter:GetChildren()) do
  23.   if v:IsA("LocalScript") then
  24.       local clone = v:Clone()
  25.       clone.Disabled = true
  26.       clone.Parent = FakeCharacter
  27.   end
  28. end
  29. if Transparency then
  30.   for i, v in pairs(FakeCharacter:GetDescendants()) do
  31.       if v:IsA("BasePart") then
  32.           v.Transparency = 0.7
  33.       end
  34.   end
  35. end
  36. local CanInvis = true
  37. function RealCharacterDied()
  38.   CanInvis = false
  39.   RealCharacter:Destroy()
  40.   RealCharacter = Player.Character
  41.   CanInvis = true
  42.   isinvisible = false
  43.   FakeCharacter:Destroy()
  44.   workspace.CurrentCamera.CameraSubject = RealCharacter.Humanoid
  45.  
  46.   RealCharacter.Archivable = true
  47.   FakeCharacter = RealCharacter:Clone()
  48.   Part:Destroy()
  49.   Part = Instance.new("Part", workspace)
  50.   Part.Anchored = true
  51.   Part.Size = Vector3.new(200, 1, 200)
  52.   Part.CFrame = CFrame.new(99999999999999999999999999999, 900, 99999999999999999999) --Set this to whatever you want, just far away from the map.
  53.   Part.CanCollide = true
  54.   FakeCharacter.Parent = workspace
  55.   FakeCharacter.HumanoidRootPart.CFrame = Part.CFrame * CFrame.new(0, 5, 0)
  56.  
  57.   for i, v in pairs(RealCharacter:GetChildren()) do
  58.       if v:IsA("LocalScript") then
  59.           local clone = v:Clone()
  60.           clone.Disabled = true
  61.           clone.Parent = FakeCharacter
  62.       end
  63.   end
  64.   if Transparency then
  65.       for i, v in pairs(FakeCharacter:GetDescendants()) do
  66.           if v:IsA("BasePart") then
  67.               v.Transparency = 0.7
  68.           end
  69.       end
  70.   end
  71.  RealCharacter.Humanoid.Died:Connect(function()
  72.  RealCharacter:Destroy()
  73.  FakeCharacter:Destroy()
  74.  end)
  75.  Player.CharacterAppearanceLoaded:Connect(RealCharacterDied)
  76. end
  77. RealCharacter.Humanoid.Died:Connect(function()
  78.  RealCharacter:Destroy()
  79.  FakeCharacter:Destroy()
  80.  end)
  81. Player.CharacterAppearanceLoaded:Connect(RealCharacterDied)
  82. local PseudoAnchor
  83. game:GetService "RunService".RenderStepped:Connect(
  84.   function()
  85.       if PseudoAnchor ~= nil then
  86.           PseudoAnchor.CFrame = Part.CFrame * CFrame.new(0, 5, 0)
  87.       end
  88.        if NoClip then
  89.       FakeCharacter.Humanoid:ChangeState(11)
  90.        end
  91.   end
  92. )
  93.  
  94. PseudoAnchor = FakeCharacter.HumanoidRootPart
  95. local function Invisible()
  96.   if IsInvisible == false then
  97.       local StoredCF = RealCharacter.HumanoidRootPart.CFrame
  98.       RealCharacter.HumanoidRootPart.CFrame = FakeCharacter.HumanoidRootPart.CFrame
  99.       FakeCharacter.HumanoidRootPart.CFrame = StoredCF
  100.       RealCharacter.Humanoid:UnequipTools()
  101.       Player.Character = FakeCharacter
  102.       workspace.CurrentCamera.CameraSubject = FakeCharacter.Humanoid
  103.       PseudoAnchor = RealCharacter.HumanoidRootPart
  104.       for i, v in pairs(FakeCharacter:GetChildren()) do
  105.           if v:IsA("LocalScript") then
  106.               v.Disabled = false
  107.           end
  108.       end
  109.  
  110.       IsInvisible = true
  111.   else
  112.       local StoredCF = FakeCharacter.HumanoidRootPart.CFrame
  113.       FakeCharacter.HumanoidRootPart.CFrame = RealCharacter.HumanoidRootPart.CFrame
  114.      
  115.       RealCharacter.HumanoidRootPart.CFrame = StoredCF
  116.      
  117.       FakeCharacter.Humanoid:UnequipTools()
  118.       Player.Character = RealCharacter
  119.       workspace.CurrentCamera.CameraSubject = RealCharacter.Humanoid
  120.       PseudoAnchor = FakeCharacter.HumanoidRootPart
  121.       for i, v in pairs(FakeCharacter:GetChildren()) do
  122.           if v:IsA("LocalScript") then
  123.               v.Disabled = true
  124.           end
  125.       end
  126.       IsInvisible = false
  127.   end
  128. end
  129.  
  130. game:GetService("UserInputService").InputBegan:Connect(
  131.   function(key, gamep)
  132.       if gamep then
  133.           return
  134.       end
  135.       if key.KeyCode.Name:lower() == Keybind:lower() and CanInvis and RealCharacter and FakeCharacter then
  136.           if RealCharacter:FindFirstChild("HumanoidRootPart") and FakeCharacter:FindFirstChild("HumanoidRootPart") then
  137.               Invisible()
  138.           end
  139.       end
  140.   end
  141. )
  142. local Sound = Instance.new("Sound",game:GetService("SoundService"))
  143. Sound.SoundId = "rbxassetid://232127604"
  144. Sound:Play()
  145. game:GetService("StarterGui"):SetCore("SendNotification",{["Title"] = "Invisible Toggle Loaded",["Text"] = "Press "..Keybind.." to become change visibility.",["Duration"] = 20,["Button1"] = "Okay."})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement