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

How do I check if someone is on a certain team?

Asked by 4 years ago
Edited 4 years ago
local Players=game:GetService("Players")
local team=game:WaitForChild("Teams")
Players.PlayerAdded:Connect(function(player)
    local num=math.random(0,6)
    if num=='1' or '2' or '3' then
        player.Team = team:FindFirstChild("sc1")
    elseif num=='4' or '5' or '6' then
        player.Team = team:FindFirstChild("sc2")
    end
    print('aaa')
    local char=game.Workspace:WaitForChild(player.Name)
    print('aaa')
    if player.Team.Name == "sc2" then
        print('aaa')
        char.Shirt.ShirtTemplate = "rbxassetid://3097432231"
        char.LeftLeg.brickcolor= BrickColor.new("Bright Red")
    end

end)

Prints the first 2 'aaa's, but when I check if the player is in the team, nothing happens, how can I properly check this?

0
Strings are truthy in Lua, so `num == '1' or '2' or '3' will always evaluate to '2' since math.random returns an integer not a string representation of it, so the condition is satisfied User#24403 69 — 4y
0
teams are not placed in game, teams are placed in the players Gameplayer365247v2 1055 — 4y

Answer this question