Advertisement
Lightyear2

Teleport gui script roblox

Nov 5th, 2023 (edited)
12,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | Gaming | 0 0
  1. local Players = game:GetService("Players")
  2. local Camera = game.Workspace.CurrentCamera
  3.  
  4. function SpectatePlayer(player)
  5.     Camera.CameraSubject = player.Character.Humanoid
  6. end
  7.  
  8. local gui = Instance.new("ScreenGui")
  9. gui.Name = "Spectate GUI"
  10. gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  11.  
  12. local frame = Instance.new("Frame")
  13. frame.Name = "Player List"
  14. frame.Size = UDim2.new(0, 200, 0, 300)
  15. frame.Position = UDim2.new(0.5, -100, 0.5, -150)
  16. frame.BackgroundColor3 = Color3.new(0, 0, 0)
  17. frame.BackgroundTransparency = 0.5
  18. frame.BorderSizePixel = 5
  19. frame.BorderColor3 = Color3.new(1, 1, 1)
  20. frame.Parent = gui
  21.  
  22. local list = Instance.new("UIListLayout")
  23. list.Parent = frame
  24.  
  25. local minimizeButton = Instance.new("TextButton")
  26. minimizeButton.Name = "Minimize"
  27. minimizeButton.Text = "-"
  28. minimizeButton.Size = UDim2.new(0, 20, 0, 20)
  29. minimizeButton.Position = UDim2.new(1, -20, 0, 0)
  30. minimizeButton.BackgroundColor3 = Color3.new(1, 1, 1)
  31. minimizeButton.Parent = frame
  32.  
  33. local isMinimized = false
  34.  
  35. minimizeButton.MouseButton1Click:Connect(function()
  36.     if isMinimized then
  37.         frame.Size = UDim2.new(0, 200, 0, 300)
  38.         isMinimized = false
  39.         minimizeButton.Text = "-"
  40.     else
  41.         frame.Size = UDim2.new(0, 200, 0, 20)
  42.         isMinimized = true
  43.         minimizeButton.Text = "+"
  44.     end
  45. end)
  46.  
  47. local isDragging = false
  48. local dragStart = nil
  49. local dragOffset = nil
  50.  
  51. frame.InputBegan:Connect(function(input)
  52.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  53.         isDragging = true
  54.         dragStart = input.Position
  55.         dragOffset = frame.Position - UDim2.new(0, dragStart.X, 0, dragStart.Y)
  56.     end
  57. end)
  58.  
  59. frame.InputEnded:Connect(function(input)
  60.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  61.         isDragging = false
  62.     end
  63. end)
  64.  
  65. frame.InputChanged:Connect(function(input)
  66.     if input.UserInputType == Enum.UserInputType.MouseMovement then
  67.         if isDragging then
  68.             local newPosition = UDim2.new(0, input.Position.X, 0, input.Position.Y) + dragOffset
  69.             frame.Position = newPosition
  70.         end
  71.     end
  72. end)
  73.  
  74. local function updatePlayerList()
  75.     for _, child in ipairs(frame:GetChildren()) do
  76.         if child:IsA("TextButton") then
  77.             child:Destroy()
  78.         end
  79.     end
  80.  
  81.     for _, player in ipairs(Players:GetPlayers()) do
  82.         local button = Instance.new("TextButton")
  83.         button.Name = player.Name
  84.         button.Text = player.Name
  85.         button.Size = UDim2.new(1, 0, 0, 50)
  86.         button.BackgroundColor3 = Color3.new(1, 1, 1)
  87.         button.Parent = frame
  88.  
  89.         button.MouseButton1Click:Connect(function()
  90.             SpectatePlayer(player)
  91.         end)
  92.     end
  93. end
  94.  
  95. Players.PlayerAdded:Connect(function(player)
  96.     player.CharacterAdded:Connect(function(character)
  97.         SpectatePlayer(player)
  98.         updatePlayerList()
  99.     end)
  100.     updatePlayerList()
  101. end)
  102.  
  103. Players.PlayerRemoving:Connect(function(player)
  104.     updatePlayerList()
  105. end)
  106.  
  107. updatePlayerList()
  108.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement