Advertisement
IsaacFG1

Roblox Spectator Mode Script

Oct 9th, 2024
21,154
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | Gaming | 0 0
  1. function start()
  2. local plr = game.Players.LocalPlayer
  3. local players = game.Players
  4. local subject = game.Players.LocalPlayer.Character.Humanoid
  5. local index = 0
  6. local setsubject = false
  7. local cam = game.Workspace.CurrentCamera
  8. for i, v in ipairs(players:GetChildren()) do
  9. if v == plr then
  10. index = i
  11. end
  12. end
  13. local gui = Instance.new("ScreenGui", plr.PlayerGui)
  14. gui.Name = "SpectatorGui"
  15. local frame = Instance.new("Frame", gui)
  16. local upbutton = Instance.new("TextButton", frame)
  17. local downbutton = Instance.new("TextButton", frame)
  18. local playernamelabel = Instance.new("TextLabel", frame)
  19. frame.Draggable = true
  20. frame.Selectable = true
  21. frame.Active = true
  22. frame.Size = UDim2.fromScale(0.4, 0.1)
  23. playernamelabel.TextScaled = true
  24. playernamelabel.Text = plr.Character.Humanoid.DisplayName
  25. playernamelabel.Size = UDim2.fromScale(0.5, 1)
  26. playernamelabel.Position = UDim2.fromScale(0.25, 0)
  27. upbutton.Text = ">"
  28. upbutton.TextScaled = true
  29. upbutton.Size = UDim2.fromScale(0.25, 1)
  30. upbutton.Position = UDim2.fromScale(0.75, 0)
  31. downbutton.Text = "<"
  32. downbutton.TextScaled = true
  33. downbutton.Size = UDim2.fromScale(0.25, 1)
  34. downbutton.Position = UDim2.fromScale(0, 0)
  35. function changeSubject(isup)
  36. setsubject = false
  37. if isup then
  38. index = index + 1
  39. else
  40. index = index - 1
  41. end
  42. if index > #players:GetChildren() then
  43. index = 0
  44. end
  45. if index < 0 then
  46. index = #players:GetChildren()
  47. end
  48. subject = players:GetChildren()[index]
  49. playernamelabel.Text = subject.Character.Humanoid.DisplayName
  50. setsubject = true
  51. while setsubject do
  52. if subject.Character then
  53. if subject.Character:FindFirstChild("Humanoid") then
  54. cam.CameraSubject = subject.Character.Humanoid
  55. end
  56. end
  57. task.wait()
  58. end
  59. end
  60. upbutton.Activated:Connect(function()
  61. changeSubject(true)
  62. end)
  63. downbutton.Activated:Connect(function()
  64. changeSubject(false)
  65. end)
  66. end
  67. while task.wait() do
  68. if not game.Players.LocalPlayer.PlayerGui:FindFirstChild("SpectatorGui") then
  69. task.spawn(start)
  70. end
  71. end
  72.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement