I’m having trouble trying to figure out how to get both team based and free for all gamemodes working in the one place.
If I’m using the Teams service, I have 3 teams (red/blue/lobby) but then in free for all what do I do from there? I can’t put all the players on 1 team, as my code would end the round (nobody on the other team). I can’t split them up, as I have weapons that prevent players from killing their own teammates. What do I do??
You could just create BoolValues/StringValues in the player(s) backpack to distinguish if they are in the round (backpack is refreshed when they die/respawn) and which team they are in.
The method above will work, but I thought I’d pitch in and give my take on a potential solution.
What I gathered from your post is that you are looking for a method that allows you to select either FFA or team based, but make it so its both easily identical. Thus, instead of using BoolValues/StringValues, you can make use of CollectionService.
First off, fundamentally FFA and TDM are the exact same. I’m assuming that the playstyle of the game will not change, so the only change in game logic should be where they spawn, how they win, and who they damage. Thus, you could always add tags to players that represent:
If they are playing in the first place
What team they are on (if there is a team)
You would want to remake your system, so when the round starts, each player has two fundamental tags (or one if FFA)
Tag 1 : “Playing” - having this tag on your own means you are able to damage in the first place
Tag 2: “YourTeamNameHere” - having this tag adds an extra factor to your damaging logic. If you have this tag, and the opponent has the same tag, then you shouldn’t be able to damage them.
As for the game logic, you need to make it clear what type of round it is. Doing so will allow you to perform different sets of logic depending on the round.
i.e
Team Deathmatch has a logic where the number of users on a team are tracked seperately, and so you’d make two functions that listen into when an object with a “Red” or “Blue” team tag is removed
Free For All has a logic where players with the “Playing” tag are tracked, and so you’d make a function that listens to whether this list is full or not.
I recommend trying to create round specific processes for different gamemodes where necessary. Tags are one way to do it but you can easily do it with boolvalues if its easier.
Can you go into a bit more depth on the CollectionService system? I have a Settings module in ServerStorage, which has a ‘TEAMS’ variable, that is basically set to true if it’s a team based gamemode, otherwise, set to false
function TeamManager:AssignPlayerToTeam(player)
if Settings.TEAMS then -- Team matches
CollectionService:AddTag(player, )
else -- Free for all
end
end
I’m not entirely sure
How to work out what team to put a player on, if it is team based game. Should be random, but if one team has more players than another then I have to make teams even
What tag to give them if it’s free for all
EDIT
This is what I got for adding the team based tags
local function putInTeam(player)
print(CollectionService:GetTagged('BlueTeam'))
local BlueTeamPlayerCount = #CollectionService:GetTagged('BlueTeam')
local RedTeamPlayerCount = #CollectionService:GetTagged('GetTeam')
if BlueTeamPlayerCount < RedTeamPlayerCount then
if player.Parent then
CollectionService:AddTag(player, 'BlueTeam')
end
elseif RedTeamPlayerCount < BlueTeamPlayerCount then
if player.Parent then
CollectionService:AddTag(player, 'RedTeam')
end
else
local CoinFlip = math.random()
if CoinFlip < 0.5 then
if player.Parent then
CollectionService:AddTag(player, 'BlueTeam')
end
else
if player.Parent then
CollectionService:AddTag(player, 'RedTeam')
end
end
end
end
Essentially you can check a user has a tag by doing:
if CollectionService:HasTag(player,"RedTeam") then
I also had a thought that you could give players one base tag, and if they’re in TDM, an additional “Team” tag to represent their team.
I.E - if they are just in FFA, they’d only need one tag, that tag being “playing”.
If they are just in TDM, they’d need one tag for “playing” and another for the team that they are on.
The advantages of doing this is you can get every player on the map in one loop, rather than having to go through each team tag’s list. You can also check to make sure that you are only dealing damage to the players that are in game (so people who are in the lobby don’t get attacked in the case of an exploit attack)