My spectate gui isn't working, while it should work fine, why?
I used these lines script it:
I get the error on line 9, _G.gameplayers is defined in another script
01 | cam = game.Workspace.CurrentCamera |
02 | local button = script.Parent:WaitForChild( 'Button' ) |
03 | local bar = script.Parent:WaitForChild( 'Bar' ) |
04 | local title = bar.Title |
05 | local prev = bar.Previous |
06 | local nextone = bar.Next |
09 | for _, v in pairs (_G.gameplayers()) do |
10 | if v.Name = = title.Text then |
17 | button.MouseButton 1 Click:connect( function () |
19 | if debounce = = false then |
23 | title.Text = game.Players:GetPlayerFromCharacter(cam.CameraSubject.Parent).Name |
24 | script.Parent.Close.Visible = true |
26 | elseif debounce = = true then |
29 | cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid |
35 | prev.MouseButton 1 Click:connect( function () |
37 | local players = _G.gameplayers |
39 | local player = players [ num- 1 ] |
40 | local playerr = players [ #players ] |
41 | if not pcall ( function () |
42 | cam.CameraSubject = game:GetService( 'Players' ) [ player ] .Character.Humanoid |
44 | cam.CameraSubject = game:GetService( 'Players' ) [ playerr ] .Character.Humanoid |
48 | title.Text = game.Players:GetPlayerFromCharacter(cam.CameraSubject.Parent).Name |
52 | nextone.MouseButton 1 Click:connect( function () |
54 | local players = _G.gameplayers |
56 | local player = players [ num+ 1 ] |
57 | local playerr = players [ 1 ] |
58 | if not pcall ( function () |
59 | cam.CameraSubject = game:GetService( 'Players' ) [ player ] .Character.Humanoid |
61 | cam.CameraSubject = game:GetService( 'Players' ) [ playerr ] .Character.Humanoid |
65 | title.Text = game.Players:GetPlayersFromCharacter(cam.CameraSubject.Parent).Name |
Click this to see how my studio looks like