Assigning a Players Team with a Trello

So I am trying to use a trello board to automatically assign specific players who are not in the group a specific team for them to spawn on. It looks like the trello data part is working as it should. However, for some reason I keep getting an error of it not being able to assign a TeamColor property hence why it cannot correctly assign the player the team for them to spawn on. I’m not sure if it’s because it’s detecting a “Brickcolor” from a normal part when it’s just the SpawnLocation’s in the games workspace.

Any suggestions on how this can be fixed? Mind you I am not familiar with how Trello API works with assigning players on a team so this is all new to me.

local HttpService = game:GetService("HttpService")
local TrelloAPIKey = "Redacted"
local TrelloAPIToken = "Redacted"
local BoardID = "Redacted"
local TeamListIDs = {
	["Maximum Security Patient"] = "Redacted",
	["Insanity Ward Patient"] = "Redacted",
}

function assignPlayerToTeam(player)
	local playerName = player.Name
	local url = string.format("https://api.trello.com/1/search?query=%s&idBoards=%s&modelTypes=cards&card_fields=idList&key=%s&token=%s",
		HttpService:UrlEncode(playerName), HttpService:UrlEncode(BoardID), TrelloAPIKey, TrelloAPIToken)
	local response = HttpService:GetAsync(url)
	local json = HttpService:JSONDecode(response)
	local card = json.cards[1]
	if card then
		local listID = card.idList
		for team, teamListID in pairs(TeamListIDs) do
			if listID == teamListID then
				player.TeamColor = team.TeamColor
				break
			end
		end
	end
end

game.Players.PlayerAdded:Connect(assignPlayerToTeam)

Error within the output, no matter how many times I fiddle with the code:

image

Hey! It seems like maybe you’re trying to get brickcolor from a string!
Within the pairs loop you do team.TeamColor but team in this context is the index in the TeamListIDs so it would equal either “Maximum Security Patient” or “Insanity Ward Patient” (You may have meant listId instead of TeamListIDs in the pairs loop) You may be trying to do something instead like

Teams:FindFirstChild(team).TeamColor

or even better just assign the player to the team with the name! If you’re trying to get a team color from the card, I’m not sure where it would be but my assumption is under card somewhere. Sorry if this is unclear it’s just a bit difficult as I’ve never used a trello library before.

That fixed the error. However, even though the Player spawns on the correct team as it should now as per the Leaderboard, the Player doesn’t spawn on the correct spawn.

If you want the player to spawn on the right point just delete the character if they exist, which will force them to respawn at the right spawn.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.