Hey, I have a spectate script with me and what it does is it lets people spectate. Problem is the killer can spectate and the runners can spectate too. How do I make it only for lobby.
Game is round based
local player = game.Players.LocalPlayer
local team
local camera = game.Workspace.CurrentCamera
local spectate = script.Parent:WaitForChild("Spectate")
local contestants = {}
local current = 1
local maxContestants = 0
game:GetService("RunService").RenderStepped:Connect(function()
contestants = {}
for i,v in pairs(game.Players:GetChildren()) do
table.insert(contestants,v)
end
camera.CameraType = Enum.CameraType.Follow
if #contestants <= maxContestants then
spectate.SpectateFrame.Visible = false
camera.CameraSubject = player.Character.Humanoid
end
if spectate.SpectateFrame.Visible == true then
local playerSpectating = contestants[current]
if not playerSpectating then playerSpectating = contestants[1] end
local char = playerSpectating.Character
if char and char:FindFirstChild("Humanoid") then camera.CameraSubject = char:FindFirstChild("Humanoid") end
spectate.SpectateFrame.Current.Text = playerSpectating.Name
elseif spectate.SpectateFrame.Visible == false then
camera.CameraSubject = player.Character.Humanoid
end
end)
spectate.SpectateButton.MouseButton1Click:Connect(function()
if #contestants <= maxContestants then return end
spectate.SpectateFrame.Visible = not spectate.SpectateFrame.Visible
end)
spectate.SpectateFrame.Back.MouseButton1Click:Connect(function()
if current == 1 then
current = #contestants
else
current -= 1
end
end)
spectate.SpectateFrame.Fwd.MouseButton1Click:Connect(function()
if current == #contestants then
current = 1
else
current += 1
end
end)