Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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:

1if player.Team.Red then
2-- scripts that you do not need to read
3end
0
is ro was? MaxDev_BE 55 — 5y
0
What do you mean? Baselistic 103 — 5y
0
He asked "is or was?" like is in the team currently or was in the team previously? kingblaze_1000 359 — 5y

3 answers

Log in to vote
1
Answered by
iuclds 720 Moderation Voter
5 years ago
1script.Parent.Touched:Connect(function(hit)
2local player = game.Players:FindFirstChild(hit.Parent.Name)
3if not player then return end
4    if player.Team.Name == "Red" then
5        -- scripts that you do not need to read
6    end
7end)
1
Thanks! It worked! I really appreciate the help. Baselistic 103 — 5y
Ad
Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

In a serverscript:

1script.Parent.Touched:Connect(function()
2    if player.Team.Name == "Red" then
3        -- scripts that you do not need to read
4    end
5end)
0
Attempt to index nil with "Team" Baselistic 103 — 5y
Log in to vote
1
Answered by
6zk8 95
5 years ago
1local player = game.Players.LocalPlayer
2 
3if player.TeamColor == "Really Red" then
4-- scripts that you do not need to read
5end
0
CHANGE REALLY RED TO THE TEAM BRICKCOLOR!!!!!!!!! 6zk8 95 — 5y
0
Attempt to index nil with "TeamColor" Baselistic 103 — 5y

Answer this question