Team-only command

GOAL: When a player says “stick”, if they are in Blue team, they get a stick. Otherwise nothing happens.

CODE:

local stick = game.Lighting.StunStick

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		
		if message:lower() == "stick" then
			if player.Team == "Blue" then
				stick:Clone().Parent = player.Backpack 
			elseif player.Team ~= "Blue" then
				print("silly, you are not blue team")
			end
		end
	end)
	
end)

ISSUE: I am in blue team but my stick is not showing up and it says that I am not in the team.

This is my output:
image

1 Like

Try Checking the TeamColor instead:

if player.TeamColor = BrickColor then
    -- code
1 Like

player.Team is just the reference of the team instance not the name.

To fix it you would do this -

if player.Team == game.Teams.Blue then
         —give tool etc

Additionally you could just do

if player.Team.Name == “Blue” then
          —give tool etc

Both methods should work

1 Like