Elvisfofo_rblx

Spectate GUI

Jun 22nd, 2025
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. local runDummyScript = function(f, scri)
  2. local oldenv = getfenv(f)
  3. local newenv = setmetatable({}, {
  4. __index = function(_, k)
  5. if k:lower() == 'script' then
  6. return scri
  7. else
  8. return oldenv[k]
  9. end
  10. end
  11. })
  12. setfenv(f, newenv)
  13. ypcall(function() f() end)
  14. end
  15.  
  16. cors = {}
  17. mas = Instance.new("Model", game:GetService("Lighting"))
  18. mas.Name = "CompiledModel"
  19.  
  20. local o1 = Instance.new("ScreenGui")
  21. local o2 = Instance.new("Frame")
  22. local o3 = Instance.new("TextButton")
  23. local o4 = Instance.new("TextButton")
  24. local o5 = Instance.new("TextLabel")
  25. local o6 = Instance.new("ImageButton")
  26. local o7 = Instance.new("LocalScript")
  27.  
  28. o1.Name = "SpectateGui"
  29. o1.Parent = game:GetService("Players").LocalPlayer.PlayerGui
  30.  
  31. o2.Name = "Bar"
  32. o2.Parent = o1
  33. o2.Position = UDim2.new(-1, -100, 0.87999999523163, -50)
  34. o2.Size = UDim2.new(0, 200, 0, 50)
  35. o2.BackgroundColor3 = Color3.new(0, 0, 0)
  36. o2.BackgroundTransparency = 0.2
  37. o2.BorderSizePixel = 5
  38.  
  39. o3.Name = "Previous"
  40. o3.Parent = o2
  41. o3.Size = UDim2.new(0.25, 0, 1, 0)
  42. o3.Text = "<"
  43. o3.BackgroundColor3 = Color3.new(0.52549, 0.52549, 0.52549)
  44. o3.BorderColor3 = Color3.new(0.509804, 0.796079, 1)
  45. o3.Font = Enum.Font.SourceSans
  46. o3.TextColor3 = Color3.new(1, 1, 1)
  47.  
  48. o4.Name = "Next"
  49. o4.Parent = o2
  50. o4.Position = UDim2.new(1, 0, 0, 0)
  51. o4.Size = UDim2.new(-0.25, 0, 1, 0)
  52. o4.Text = ">"
  53. o4.BackgroundColor3 = Color3.new(0.52549, 0.52549, 0.52549)
  54. o4.BorderColor3 = Color3.new(0.509804, 0.796079, 1)
  55. o4.Font = Enum.Font.SourceSans
  56. o4.TextColor3 = Color3.new(1, 1, 1)
  57.  
  58. o5.Name = "Title"
  59. o5.Parent = o2
  60. o5.Position = UDim2.new(0.275, 0, 0, 0)
  61. o5.Size = UDim2.new(0.45, 0, 1, 0)
  62. o5.Text = ""
  63. o5.BackgroundColor3 = Color3.new(1, 1, 1)
  64. o5.BackgroundTransparency = 1
  65. o5.Font = Enum.Font.SourceSans
  66. o5.TextColor3 = Color3.new(1, 1, 1)
  67. o5.TextSize = 30 -- Increased TextSize to make the names bigger
  68. o5.TextScaled = true
  69.  
  70. o6.Name = "Button"
  71. o6.Parent = o1
  72. o6.Position = UDim2.new(0, 0, 0.5, -25)
  73. o6.Size = UDim2.new(0, 50, 0, 50)
  74. o6.BackgroundColor3 = Color3.new(1, 1, 1)
  75. o6.BackgroundTransparency = 0.3
  76. o6.Image = "http://www.roblox.com/asset/?id=176106970"
  77.  
  78. o7.Parent = o1
  79. table.insert(cors, coroutine.create(function()
  80. wait()
  81. runDummyScript(function()
  82. local cam = game.Workspace.CurrentCamera
  83. local bar = script.Parent.Bar
  84. local title = bar.Title
  85. local prev = bar.Previous
  86. local nex = bar.Next
  87. local button = script.Parent.Button
  88.  
  89. local players = game.Players:GetPlayers()
  90. local currentIndex = 1 -- Start at the first player
  91.  
  92. -- Function to update the camera and title text
  93. local function updateCameraAndTitle(index)
  94. local player = players[index]
  95. if player and player.Character then
  96. cam.CameraSubject = player.Character.Humanoid
  97. title.Text = string.format("%s (@%s)", player.DisplayName, player.Name)
  98. end
  99. end
  100.  
  101. -- Initialize the camera to the first player
  102. updateCameraAndTitle(currentIndex)
  103.  
  104. -- Button to toggle between first-person and spectate mode
  105. local debounce = false
  106. button.MouseButton1Click:Connect(function()
  107. if debounce == false then
  108. debounce = true
  109. bar:TweenPosition(UDim2.new(.5, -100, 0.88, -50), "In", "Linear", 0.2, true)
  110. pcall(function()
  111. local player = game.Players:GetPlayerFromCharacter(cam.CameraSubject.Parent)
  112. title.Text = string.format("%s (@%s)", player.DisplayName, player.Name)
  113. end)
  114. elseif debounce == true then
  115. debounce = false
  116. pcall(function() cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid end)
  117. bar:TweenPosition(UDim2.new(-1, -100, 0.88, -50), "In", "Linear", 0.2, true)
  118. end
  119. end)
  120.  
  121. -- Previous button click
  122. prev.MouseButton1Click:Connect(function()
  123. currentIndex = currentIndex - 1
  124. if currentIndex < 1 then
  125. currentIndex = #players -- Wrap to last player if going before the first player
  126. end
  127. updateCameraAndTitle(currentIndex)
  128. end)
  129.  
  130. -- Next button click
  131. nex.MouseButton1Click:Connect(function()
  132. currentIndex = currentIndex + 1
  133. if currentIndex > #players then
  134. currentIndex = 1 -- Wrap to first player if going past the last player
  135. end
  136. updateCameraAndTitle(currentIndex)
  137. end)
  138. end, o7)
  139. end))
  140.  
  141. mas.Parent = game:GetService("Players").LocalPlayer.PlayerGui
  142. mas:MakeJoints()
  143. local mas1 = mas:GetChildren()
  144. for i = 1, #mas1 do
  145. mas1[i].Parent = game:GetService("Players").LocalPlayer.PlayerGui
  146. ypcall(function() mas1[i]:MakeJoints() end)
  147. end
  148. mas:Destroy()
  149. for i = 1, #cors do
  150. coroutine.resume(cors[i])
  151. end
Add Comment
Please, Sign In to add comment