Capture the point system player detection

Hello, i am trying to do capture the point using Region3, but i am here to ask if there are any better ways for that

2 Likes

Region3 are deprecated, you should use their new and better replacement OverlapParams, or even the newest shapecasts.

1 Like

After few days i got the same problem… I asked in the first place because my Region3 couldn’t detect player leaving the Region3, but here we are again, it worked few days ago but it doesn’t now


What part doesn’t work? Adding the players? Or removing them?

Removing part keeps the player in even when 30000 studs away

There’s a couple issues with your code. First of all you’re using break when you should use continue. If there’s more than 1 player and you use break, the whole loop will stop.

if player.Character.Humanoid.Health > 0 then
   continue;
end;

^ Same thing for the other case where you use table.remove

Second issue is the way you’re using table.remove. You see, once you remove an index from the table, the next index will replace it. So if you remove index 3, the 4 will now be the new 3 so if the next player that needs to be removed was index 5, index 4 would instead be removed when it probably shouldn’t be. To fix that you can just use table.find

table.remove(playerInBounds, table.find(playerInBounds, player)); -- always finds the correct index
1 Like


None of it fixed it sadly

Because you’re updating the Regionparts variable everytime with new parts. Create an array (let’s call it X) and keep every player found in it, then loop through playerInBounds and check if the player is in X. If it’s not then remove the player from playerInBounds.

Wdym, a table or? I also don’t under what is gonna change cause it’ll do the same work as it does now

If you update the Regionparts variable everytime BEFORE running the remove function, if a player is outside of the region then there won’t be any of their parts in the Regionparts array so that :GetPlayerFromCharacter check will never be true and the player will never be removed. Also i’m unsure what that partIndex == #Regionparts does

Yes a table

image
Like that?

No, just create a table and insert every player you find through Regionparts so then you can filter out the ones that aren’t in the region from playerInBounds

local foundPlayers = {};

-- in your removeOldPlayers function, inside the loop
local playerFromPart = game.Players:GetPlayerFromCharacter(part.Parent);
if playerFromPart then
   table.insert(foundPlayers, playerFromPart);
end;

-- after the loop is over, still in your removeOldPlayers function
for _, player in ipairs(playerInBounds) do
   if table.find(foundPlayers, player) == nil then
      table.remove(playerInBounds, table.find(playerInBounds, player));
   end;
end;


Still doesn’t work

Btw i tried putting it after all loops end and still it didn’t

Oh my god damn lord, we are free the reason it didn’t work is because the radius wasn’t touching baseplate :skull: no cap, it’s only because of that

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