Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Teaming someone when player is added does not work?

Whenever I try to team someone in the playeradded it doesn't team them, it is wierd cause it was working a week ago.

(Yes this is in a server script) (Also if I try printing something it does work, it is simply just not teaming the player)

USM = "United States Army"
JMP = "Military Police"
VISITOR = "Visitors"

local Players = game:GetService("Players")
 
Players.PlayerAdded:Connect(function(player)
	if player:IsInGroup(4490133) then
	print("yee")
	player.TeamColor = BrickColor.new("Fossil")
	elseif player:IsInGroup(4490133) then
	player.TeamColor = game.Teams[USM].TeamColor
	else
	player.TeamColor = game.Teams[VISITOR].TeamColor
	end
end)

1 comment

0

any errors in console?

1 answer

Just try this:

USM = "United States Army"
JMP = "Military Police"
VISITOR = "Visitors"

local Players = game:WaitForChild("Players")

Players.PlayerAdded:Connect(function(player)
    if player:IsInGroup(4490133) then
    print("yee")
    player.TeamColor = BrickColor.new("Fossil")
    elseif player:IsInGroup(4490133) then
    player.TeamColor = game.Teams:FindFirstChild(USM).TeamColor
    else
    player.TeamColor = game.Teams:FindFirstChild(VISITOR).TeamColor
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.