Advertisement
Stevejjj

Script

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