How could I achieve Capture Objective / King of The Hill?

I suggest starting with player detection first, for this I suggest the zone + module, pretty simple and easy to use.

Track teams in a capture point zone in a table


		local playersInsideZone = {}
		local BlueTeamContestants = {}
		local RedTeamContestants = {}
		local detectionLoop = nil --Heartbeat connection that is created to reward points if players are in zone every frame

		zone.playerEntered:Connect(function(player : Player)
			print(("%s entered the zone!"):format(player.Name))
			playersInsideZone[player] = true
			local team = player.Team
			if not team then
				warn("Player team missing", player, team)
				return
			end
			if team.Name == "Blue" then
				table.insert(BlueTeamContestants, player)
			elseif team.Name == "Red" then
				table.insert(RedTeamContestants, player)
			end

Once you get the total number of players and teams on a point then you can start writing the rest of the logic.

1 Like