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

How do i check if a player was in a team?

Hi! I'm making a tycoon and I ran into a problem. I wanted to make the player only touch the button if he was in the right team and I used this and it doesn't work:

if player.Team.Red then
-- scripts that you do not need to read
end

3 comments

0

is ro was?

0

What do you mean?

0

He asked "is or was?" like is in the team currently or was in the team previously?

3 answers

✓ Accepted answer
script.Parent.Touched:Connect(function(hit)
local player = game.Players:FindFirstChild(hit.Parent.Name)
if not player then return end
    if player.Team.Name == "Red" then
        -- scripts that you do not need to read
    end
end)

1 comment

1

Thanks! It worked! I really appreciate the help.

In a serverscript:

script.Parent.Touched:Connect(function()
	if player.Team.Name == "Red" then
		-- scripts that you do not need to read
	end
end)

1 comment

0

Attempt to index nil with "Team"

local player = game.Players.LocalPlayer

if player.TeamColor == "Really Red" then
-- scripts that you do not need to read
end

2 comments

0

CHANGE REALLY RED TO THE TEAM BRICKCOLOR!!!!!!!!!

0

Attempt to index nil with "TeamColor"

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