Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a capture point for multiple teams?

As the title suggests, I am trying to make a capture point in my own game for multiple teams.

I am trying to make it so that if more than 1 team is standing ontop of a point, it will display that the point has been contested.

But how would the script know if there were different teams ontop of the part? This is where I'm stuck. Any help is appreciated, cheers.

1 comment

0

Id would look into using magnitude and using collectionservice or just the teamservice to determine which teams are on the capture point

1 answer

✓ Accepted answer

Run a loop through the players that are on the point and do a team check.


You can get the player's team through the player object.

Lets say you want the point to be contested if one player from a different team is on it. This is quite simple since you need to check if all players on the point are on the same team.

local playersOnPoint = {}

local teamOnPoint = playersOnPoint[1].Team --grabs 1st player's team on the point

for i=1, #playersOnPoint do
	local player = playersOnPoint[i]
	if (player.Team ~= teamOnPoint) then
		-- Contested because a player on the point isn't on the team
	end
end
-- Capturable because all players on point are on the same team

Make this a function and you can check and apply the ownership of the point.

If you want the team with the most players on the point to capture it, store a table of teams on the point and assign them numbers. Determine which time is more prominent and apply ownership.

Good luck.

This discussion is preserved as it was. New answers, comments, and votes are closed.