Hello! I have a Spectate mode script that works, everywhere, but I'd like it to only work while inside the Lobby.

Currently, I have the "ResetOnSpawn" box checked so that when a player dies in the game, the Spectate Mode is reset when they reappear in the Lobby, but if the player has it turned on while in the Lobby, when they teleport to the Game Map, Spectate Mode is still on.

Is there an easy way to do it? I know the code below is horribly wrong, but its where I've started. Any suggestions is much appreciated. Thank you! :)


local players = nil
local number = 1
local maxnumber = 0
local player = game.Players.LocalPlayer

-- Broken Script Below
if player.Lobby then player.PlayerGui.SpectateGui = true
else player.PlayerGui.SpectateGui = false
end	
-- Broken Script Above

script.Parent.Next.MouseButton1Click:connect(function(right)
	players = game.Players:GetChildren()
	number = number + 1
	if players[number] ~= nil then
		game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
		if players[number].Name ~= player.Name then
			script.Parent.PlayerName.Text = players[number].Name
		else 
			script.Parent.PlayerName.Text = "Nobody"
		end
	elseif players[number] == nil then
		number = 1
		game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
		if players[number].Name ~= player.Name then
			script.Parent.PlayerName.Text = players[number].Name
		else 
			script.Parent.PlayerName.Text = "Nobody"
		end
	end
end)

script.Parent.Previous.MouseButton1Click:connect(function(left)
	players = game.Players:GetChildren()
	maxnumber = #players
	number = number - 1
	if players[number] ~= nil then
		game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
		if players[number].Name ~= player.Name then
			script.Parent.PlayerName.Text = players[number].Name
		else 
			script.Parent.PlayerName.Text = "Nobody"
		end
	elseif players[number] == nil then
		number = maxnumber
		game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
		if players[number].Name ~= player.Name then
			script.Parent.PlayerName.Text = players[number].Name
		else 
			script.Parent.PlayerName.Text = "Nobody"
		end
	end
end)

script.Parent.Parent.SpectateButton.Spectate.MouseButton1Down:connect(function(click)
	if script.Parent.Parent.Active.Value == false then
		script.Parent.Parent.Active.Value = true
		script.Parent.Parent.ChangePlayer.Visible = true
	elseif script.Parent.Parent.Active.Value == true then
		script.Parent.Parent.Active.Value = false
		script.Parent.Parent.ChangePlayer.Visible = false
		script.Parent.PlayerName.Text = "Nobody"
		number = 1
		game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
	end
end)

3 comments

0

Can i see the whole script?

0

Edited the first post to include the rest of the script. :)

0

Anyone else have a suggestion? :)