Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local Camera = game.Workspace.CurrentCamera
- function SpectatePlayer(player)
- Camera.CameraSubject = player.Character.Humanoid
- end
- local gui = Instance.new("ScreenGui")
- gui.Name = "Spectate GUI"
- gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- local frame = Instance.new("Frame")
- frame.Name = "Player List"
- frame.Size = UDim2.new(0, 200, 0, 300)
- frame.Position = UDim2.new(0.5, -100, 0.5, -150)
- frame.BackgroundColor3 = Color3.new(0, 0, 0)
- frame.BackgroundTransparency = 0.5
- frame.BorderSizePixel = 5
- frame.BorderColor3 = Color3.new(1, 1, 1)
- frame.Parent = gui
- local list = Instance.new("UIListLayout")
- list.Parent = frame
- local minimizeButton = Instance.new("TextButton")
- minimizeButton.Name = "Minimize"
- minimizeButton.Text = "-"
- minimizeButton.Size = UDim2.new(0, 20, 0, 20)
- minimizeButton.Position = UDim2.new(1, -20, 0, 0)
- minimizeButton.BackgroundColor3 = Color3.new(1, 1, 1)
- minimizeButton.Parent = frame
- local isMinimized = false
- minimizeButton.MouseButton1Click:Connect(function()
- if isMinimized then
- frame.Size = UDim2.new(0, 200, 0, 300)
- isMinimized = false
- minimizeButton.Text = "-"
- else
- frame.Size = UDim2.new(0, 200, 0, 20)
- isMinimized = true
- minimizeButton.Text = "+"
- end
- end)
- local isDragging = false
- local dragStart = nil
- local dragOffset = nil
- frame.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- isDragging = true
- dragStart = input.Position
- dragOffset = frame.Position - UDim2.new(0, dragStart.X, 0, dragStart.Y)
- end
- end)
- frame.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- isDragging = false
- end
- end)
- frame.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement then
- if isDragging then
- local newPosition = UDim2.new(0, input.Position.X, 0, input.Position.Y) + dragOffset
- frame.Position = newPosition
- end
- end
- end)
- local function updatePlayerList()
- for _, child in ipairs(frame:GetChildren()) do
- if child:IsA("TextButton") then
- child:Destroy()
- end
- end
- for _, player in ipairs(Players:GetPlayers()) do
- local button = Instance.new("TextButton")
- button.Name = player.Name
- button.Text = player.Name
- button.Size = UDim2.new(1, 0, 0, 50)
- button.BackgroundColor3 = Color3.new(1, 1, 1)
- button.Parent = frame
- button.MouseButton1Click:Connect(function()
- SpectatePlayer(player)
- end)
- end
- end
- Players.PlayerAdded:Connect(function(player)
- player.CharacterAdded:Connect(function(character)
- SpectatePlayer(player)
- updatePlayerList()
- end)
- updatePlayerList()
- end)
- Players.PlayerRemoving:Connect(function(player)
- updatePlayerList()
- end)
- updatePlayerList()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement