Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- StarterPlayerScripts/PhantomLocalScript.lua
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- local camera = game:GetService("Workspace").CurrentCamera
- local userInputService = game:GetService("UserInputService")
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "PhantomGUI"
- screenGui.Parent = player:WaitForChild("PlayerGui")
- local button = Instance.new("TextButton")
- button.Size = UDim2.new(0, 200, 0, 50)
- button.Position = UDim2.new(0.5, -100, 0.5, -25)
- button.Text = "Become a Phantom"
- button.Parent = screenGui
- local isPhantom = false
- local originalPosition = humanoidRootPart.Position
- local function togglePhantom()
- if isPhantom then
- for _, part in ipairs(character:GetChildren()) do
- if part:IsA("BasePart") then
- part.Transparency = 0
- part.CanCollide = true
- end
- end
- humanoidRootPart.CFrame = CFrame.new(originalPosition)
- isPhantom = false
- button.Text = "Become a Phantom"
- else
- for _, part in ipairs(character:GetChildren()) do
- if part:IsA("BasePart") then
- part.Transparency = 1
- part.CanCollide = false
- end
- end
- originalPosition = humanoidRootPart.Position
- local offset = Vector3.new(math.random(-5, 5), 0, math.random(-5, 5))
- humanoidRootPart.CFrame = humanoidRootPart.CFrame + offset
- isPhantom = true
- button.Text = "Return to Place"
- end
- end
- button.MouseButton1Click:Connect(togglePhantom)
- local dragging = false
- local dragInput, dragStart, startPos
- local function update(input)
- local delta = input.Position - dragStart
- screenGui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
- end
- button.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- dragStart = input.Position
- startPos = screenGui.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- button.InputChanged:Connect(function(input)
- if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
- update(input)
- end
- end)
- local nickname = Instance.new("TextLabel")
- nickname.Size = UDim2.new(0, 200, 0, 50)
- nickname.Position = UDim2.new(0.5, -100, 0.6, -25)
- nickname.Text = "YT: Stevevan090"
- nickname.TextColor3 = Color3.fromRGB(255, 255, 255)
- nickname.BackgroundTransparency = 1
- nickname.Parent = screenGui
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement