I have a script that gets a team by its brickcolor.
local function GetTeamByBrickColor(brickcolor: BrickColor)
for i, team in pairs(Teams:GetTeams()) :: {Team} do
if team.TeamColor == brickcolor then
return team
end
end
error(`No team with brickcolor {brickcolor.Name}`)
end
When run, with the type annotation {Team}
, I get the error:
By simply removing the annotation, it works fine.
Extra info:
I’m using the run
test (so only server, no clients).
How to repo:
Create an empty place.
Create two server scripts.
In one server script, paste in this code:
local function GetTeamByBrickColor(brickcolor: BrickColor)
for i, team in pairs(Teams:GetTeams()) :: {Team} do
if team.TeamColor == brickcolor then
return team
end
end
error(`No team with brickcolor {brickcolor.Name}`)
end
In the other script,
local function GetTeamByBrickColor(brickcolor: BrickColor)
for i, team in pairs(Teams:GetTeams()) do
if team.TeamColor == brickcolor then
return team
end
end
error(`No team with brickcolor {brickcolor.Name}`)
end
Select the Run
option in testing, then run.
Expected behavior
I expect annotations to not affect how a script functions.