to spectate player again i must click back and next again. pls help me 0:)
local debounce = false
local cam = game.Workspace.CurrentCamera
----------------
local bar = script.Parent.Bar
local title = bar.Title
local prev = bar.Previous
local nex = bar.Next
local button = script.Parent.SpectateButton
----------------
local players = nil
local number = 1
local maxnumber = 0
local player = game.Players.LocalPlayer
local lastplayer = player.Name
local activation = player:WaitForChild("Activation")
----------------
local playerMod = require(player.PlayerScripts:WaitForChild("PlayerModule"))
local controls = playerMod:GetControls()
---------------- right >
nex.MouseButton1Click:Connect(function(right)
if debounce == true then
players = game.Players:GetChildren()
number = number + 1
if players[number] ~= nil then
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
lastplayer = players[number].Name
print(lastplayer)
if players[number].Name ~= player.Name then
script.Parent.Bar.StagesValue.Texta.Text = ":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
players[number]:WaitForChild("leaderstats"):WaitForChild("Stage"):GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Bar.StagesValue.Texta.Text =":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
end)
script.Parent.Bar.Title.Texta.Text = players[number].Name
else
script.Parent.Bar.StagesValue.Texta.Text = script.Parent.StagesValue.Texta.Text
script.Parent.Bar.Title.Texta.Text = "You"
end
elseif players[number] == nil then
number = 1
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
lastplayer = players[number].Name
if players[number].Name ~= player.Name then
script.Parent.Bar.StagesValue.Texta.Text = ":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
players[number]:WaitForChild("leaderstats"):WaitForChild("Stage"):GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Bar.StagesValue.Texta.Text =":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
end)
script.Parent.Bar.Title.Texta.Text = players[number].Name
else
script.Parent.Bar.StagesValue.Texta.Text = script.Parent.StagesValue.Texta.Text
script.Parent.Bar.Title.Texta.Text = "You"
end
end
end
end)
-- left <
prev.MouseButton1Click:Connect(function(left)
if debounce == true then
players = game.Players:GetChildren()
maxnumber = #players
number = number - 1
if players[number] ~= nil then
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
lastplayer = players[number].Name
print(lastplayer)
if players[number].Name ~= player.Name then
script.Parent.Bar.StagesValue.Texta.Text = ":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
players[number]:WaitForChild("leaderstats"):WaitForChild("Stage"):GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Bar.StagesValue.Texta.Text =":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
end)
script.Parent.Bar.Title.Texta.Text = players[number].Name
else
script.Parent.Bar.StagesValue.Texta.Text = script.Parent.StagesValue.Texta.Text
script.Parent.Bar.Title.Texta.Text = "You"
end
elseif players[number] == nil then
number = maxnumber
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
lastplayer = players[number].Name
if players[number].Name ~= player.Name then
script.Parent.Bar.StagesValue.Texta.Text = ":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
players[number]:WaitForChild("leaderstats"):WaitForChild("Stage"):GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Bar.StagesValue.Texta.Text =":checkered_flag: Stage: "..players[number]:WaitForChild("leaderstats"):WaitForChild("Stage").Value
end)
script.Parent.Bar.Title.Texta.Text = players[number].Name
else
script.Parent.Bar.StagesValue.Texta.Text = script.Parent.StagesValue.Texta.Text
script.Parent.Bar.Title.Texta.Text = "You"
end
end
end
end)
--- on
button.MouseButton1Click:Connect(function(click)
if debounce == false and activation.Value == false then debounce = true
controls:Disable()
activation.Value = true
script.Parent.Bar.StagesValue.Texta.Text = script.Parent.StagesValue.Texta.Text
bar:TweenPosition(UDim2.new(0, 0, 0, 0),"In","Linear",1,true)
elseif debounce == true and activation.Value == true then debounce = false
controls:Enable()
activation.Value = false
script.Parent.Bar.Title.Texta.Text = "You"
lastplayer = player.Name
script.Parent.Bar.StagesValue.Texta.Text = script.Parent.StagesValue.Texta.Text
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
number = 1
bar:TweenPosition(UDim2.new(1, 0, 0, 0),"In","Linear",1,true)
end
end)
