Advertisement
Stevejjj

Ghost script

Nov 20th, 2024 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.33 KB | Source Code | 0 0
  1. local player = game.Players.LocalPlayer
  2. local character = player.Character or player.CharacterAdded:Wait()
  3. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  4. local camera = game:GetService("Workspace").CurrentCamera
  5. local userInputService = game:GetService("UserInputService")
  6.  
  7. local screenGui = Instance.new("ScreenGui")
  8. screenGui.Name = "PhantomGUI"
  9. screenGui.Parent = player:WaitForChild("PlayerGui")
  10.  
  11. local frame = Instance.new("Frame")
  12. frame.Size = UDim2.new(0, 300, 0, 150)
  13. frame.Position = UDim2.new(0.5, -150, 0.5, -75)
  14. frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  15. frame.BackgroundTransparency = 0.5
  16. frame.Parent = screenGui
  17.  
  18. local button = Instance.new("TextButton")
  19. button.Size = UDim2.new(0, 200, 0, 50)
  20. button.Position = UDim2.new(0.5, -100, 0.2, 0)
  21. button.Text = "Become a Phantom"
  22. button.Parent = frame
  23.  
  24. local isPhantom = false
  25. local originalPosition = humanoidRootPart.Position
  26.  
  27. local function togglePhantom()
  28.     if isPhantom then
  29.         for _, part in ipairs(character:GetChildren()) do
  30.             if part:IsA("BasePart") then
  31.                 part.Transparency = 0
  32.                 part.CanCollide = true
  33.             end
  34.             if part:IsA("Accessory") then
  35.                 local handle = part:FindFirstChild("Handle")
  36.                 if handle then
  37.                     handle.Transparency = 0
  38.                 end
  39.             end
  40.         end
  41.         humanoidRootPart.CFrame = CFrame.new(originalPosition)
  42.         isPhantom = false
  43.         button.Text = "Become a Phantom"
  44.     else
  45.         for _, part in ipairs(character:GetChildren()) do
  46.             if part:IsA("BasePart") then
  47.                 part.Transparency = 1
  48.                 part.CanCollide = false
  49.             end
  50.             if part:IsA("Accessory") then
  51.                 local handle = part:FindFirstChild("Handle")
  52.                 if handle then
  53.                     handle.Transparency = 1
  54.                 end
  55.             end
  56.         end
  57.         originalPosition = humanoidRootPart.Position
  58.         isPhantom = true
  59.         button.Text = "Return to Place"
  60.     end
  61. end
  62.  
  63. button.MouseButton1Click:Connect(togglePhantom)
  64.  
  65. local dragging = false
  66. local dragInput, dragStart, startPos
  67.  
  68. local function update(input)
  69.     local delta = input.Position - dragStart
  70.     frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  71. end
  72.  
  73. frame.InputBegan:Connect(function(input)
  74.     if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  75.         dragging = true
  76.         dragStart = input.Position
  77.         startPos = frame.Position
  78.         input.Changed:Connect(function()
  79.             if input.UserInputState == Enum.UserInputState.End then
  80.                 dragging = false
  81.             end
  82.         end)
  83.     end
  84. end)
  85.  
  86. frame.InputChanged:Connect(function(input)
  87.     if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
  88.         update(input)
  89.     end
  90. end)
  91.  
  92. local nickname = Instance.new("TextLabel")
  93. nickname.Size = UDim2.new(0, 200, 0, 50)
  94. nickname.Position = UDim2.new(0.5, -100, 0.8, 0)
  95. nickname.Text = "YT: Stevevan090"
  96. nickname.TextColor3 = Color3.fromRGB(255, 255, 255)
  97. nickname.BackgroundTransparency = 1
  98. nickname.Parent = frame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement