-
How would I make it so it checks multiple teams if they player is on that team then do script
-
Don’t know how to do that
You can index the player’s .Team property to see what team they are on.
local Team = Player.Team
print(Player, "is on Team", Team)
I want to check multiple teams at once, so if they are on x team or y team then the script will function
Inside a local script:
local player = game.Players.LocalPlayer
local team = player.Team
if team.Name == "A" then --some team name
--do some action
elseif team.Name == "B" then --some other team name
--do some other action
else --if they belong to neither the team A or the team B
--do something else
end
Another version of @Limited_Unique’s method would be:
local teams = game:GetService("Teams") -- the 'Teams' service that holds the teams in the game
local player = game:GetService("Players").LocalPlayer
local playerTeam = player.Team
local teamFunctions = { -- a dictionary to hold the team function because writing a ton of elseifs isn't efficient
[teams.MyTeam] = function()
-- a function that has a team as the index
end
}
if teamFunctions[playerTeam] then
--checks if the player's team is in the dictionary
teamFunctions[playerTeam]() -- call the function attached to the index
else
-- player's team is not in the dictionary
end