heyooo my knowledge on coding is pretty low at this point so i figured I’d have ChatGPT help me out for a little. it gave me two different codes for my situation. Essentially i need for verse to determine how many players per team based off total number of players. 1 member on team 2 if there are five to seven players. 2 members on team 2 if there are eight to ten players. and 3 members on team 2 if there are eleven to fifteen players. I’m trying to make a game very similar to Town of Salem and the like as I’ve got the card game but it’s just easier to try and do it in fortnite where one player doesn’t have to sit out to be the narrator and not everyone wants to go and play the app on their phone. this was the initial code it gave me
Function to determine team sizes based on player count
func DetermineTeams(playerCount: int) → (int, int) {
// Initialize team sizes
local team1Size = 0
local team2Size = 0
// Determine team sizes based on player count
if playerCount >= 5 && playerCount <= 7 {
team1Size = playerCount - 1
team2Size = 1
} else if playerCount >= 8 && playerCount <= 10 {
team1Size = playerCount - 2
team2Size = 2
} else if playerCount >= 11 && playerCount <= 15 {
team1Size = playerCount - 3
team2Size = 3
} else {
// Handle cases with fewer than 5 players or more than 15
team1Size = playerCount // All players in team 1
team2Size = 0 // No players in team 2
}
return (team1Size, team2Size)
}
Example usage
on PlayerJoined(player: Player) {
local playerCount = GetPlayerCount() // Function to get current player count
local (team1Size, team2Size) = DetermineTeams(playerCount)
Print("Team 1 size: " + team1Size)
Print("Team 2 size: " + team2Size)
}
and this was the one it most recently gave me after multiple issues with the “func DetermineTeams(playerCount: int) → (int, int) {” line
TeamCollection instance to manage player teams
var teamCollection := TeamCollection{}
Function to calculate and assign players to teams based on total player count
fn AssignTeamsBasedOnPlayerCount(totalPlayers: int) =
# Clear any previous team assignments
teamCollection.Clear()
# Initialize team sizes
var team1Size := 0
var team2Size := 0
# Determine team sizes based on total player count
if (totalPlayers >= 5 && totalPlayers <= 7) then
team1Size := totalPlayers - 1 # Team 1 gets the rest
team2Size := 1 # Team 2 gets 1 player
else if (totalPlayers >= 8 && totalPlayers <= 10) then
team1Size := totalPlayers - 2 # Team 1 gets the rest
team2Size := 2 # Team 2 gets 2 players
else if (totalPlayers >= 11 && totalPlayers <= 15) then
team1Size := totalPlayers - 3 # Team 1 gets the rest
team2Size := 3 # Team 2 gets 3 players
else
# All players assigned to Team 1 if fewer than 5 or more than 15 players
team1Size := totalPlayers
team2Size := 0
# Assign players to teams
teamCollection.AddTeam(1, team1Size)
teamCollection.AddTeam(2, team2Size)
# Output team sizes for debugging
Print("Team 1 size: " + team1Size.ToString())
Print("Team 2 size: " + team2Size.ToString())
Define the event that triggers team assignment
event OnPlayerJoin(player: Player) =
# Capture the current player count in a variable
var currentPlayers := GetPlayerCount()
# Call the team assignment function with the current player count
AssignTeamsBasedOnPlayerCount(currentPlayers)
any help would be lovely thank you
after posting i noticed that the auto formating kinda messed up my examples and i don’t really know how to fix that i’m sorry