Making a spectating team

Try this:

-- writen by achdef --
-- local script --

local player
local team = game:GetService("Teams")

while true do
game.Players.PlayerAdded:Connect(function()
player = game.Players.LocalPlayer
if player.Team == team["Spectating"] or team.Spectating then
script.Parent.Parent.Visible = true
wait(5)
print("Success") -- for debugging
else
warn("Error") -- for debugging
  end
 end)
end

found it.

local players = game:GetService("Players")

local player = players.LocalPlayer

if player.Team == game.Teams.Spectating then

script.Parent.Parent.Parent.Visible = true

end

if there are any issues just reply back to me.

So weird like it doesn’t show up

it works for me but i guess i loaded it in when i auto-assigned it.

Ye I’m using HD admin so I can change my team manually

i wouldn’t wanna use this but i shortened it and added a while wait even if i didn’t want to, see if this works.

local players = game:GetService("Players")

local plr = players.LocalPlayer

while wait(2) do -- change wait time it's optional
if plr.Team == game.Teams.Spectating then
	script.Parent.Parent.Parent.Visible = true
	end
	end

you probably have a virus in game

No it’s not, i didn’t work for me until i added the new script.

Nah fam It’s a new baseplate
I was thinking about a team.Changed

did you try the fixed script i made with plr?

First, the while true do loop is not needed. Second, im pretty sure your error is that you’re checking if they are on spectate team immediately after they join. Maybe wait until they pick the team or die?

Ye That’s why I was thinking about a Team.Changed

I would wait until they die / choose to spectate, then use Player.PlayerGui.ScreenGui.Frame.Visible = true

1 Like

When I do ;team me it automaticly reset my character

In that case use

game.Players.LocalPlayer.Team.Changed:Connect(function()
– make visible
end)

Try this: (not sure if it works haven’t tested it yet.)

local player = game:GetService('Players').LocalPlayer
local teams = game:GetService('Teams')

local ui = script.Parent.Parent.Parent

player:GetPropertyChangedSignal('Team'):Connect(function()
if player.Team == teams.Spectator then
ui.Visible = true
else
ui.Visible = false
end
end)

Hi! This is only my second reply to a post, but I’ll give my tips. I would check if the Team Color of the player is the same as the Team Color of the Spectating team. (I think you’re doing this on the client-side?)

local Player = game.Players.LocalPlayer
local Teams = game:GetService("Team")
local Spectating = Teams:WaitForChild("Spectating")

function CheckIfOnTeamSpectate()
    if Player.TeamColor == Spectating.TeamColor then -- If the player is on the Spectating team
        script.Parent.Parent.Parent.Visible = true -- Show the gui
    else -- If the player isn't on the Spectating team
        script.Parent.Parent.Parent.Visible = false -- Hide the gui
    end
end

CheckIfOnTeamSpectate() -- Checks in the beginning of the game

Player:GetPropertyChangedSignal("TeamColor"):Connect(function() -- Connects whenever the player changes team
    CheckIfOnTeamSpectate()
end)

Hope this helps!

I think the problem come from the GUI cuz nothing work, maybe I’ll make it change its position