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 4 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:

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

3 answers

Log in to vote
1
Answered by
iuclds 720 Moderation Voter
4 years ago
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
Thanks! It worked! I really appreciate the help. Baselistic 103 — 4y
Ad
Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

In a serverscript:

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

if player.TeamColor == "Really Red" then
-- scripts that you do not need to read
end
0
CHANGE REALLY RED TO THE TEAM BRICKCOLOR!!!!!!!!! 6zk8 95 — 4y
0
Attempt to index nil with "TeamColor" Baselistic 103 — 4y

Answer this question