I have a lobby and an arena, as simple as possible I want the player's maxhealth to increase to infinite in the lobby and back to 100 in the arena. The obvious choice is to create a big false cancollide invisible block, and have a touched event in the part changing health. I don't want to do this because it's extremely exploitable (exploiters can move the part, change the part's size, bring the part, delete the part etc) and there's too many things to prevent.
I want to use either Region3s (exploiters can't "bring" a region3) or Raycasting as it's more secure and I believe a better method. I'm unsure if using a Region3 will lag my game if the lobby has lets say over 500 parts in it, or if Raycasting is better performance wise and in general? Which one is best for performance and security/efficiency? Thanks.
EDIT:
I just checked, using a while wait() loop with Region3 in my lobby doesn't seem to cause much lag, but when there are more players it probably will, the lobby has around 550 parts.
Region3 would be the best method out of the two. If you were to use Region3s to detect characters, you could iterate through all the players and add their characters to a whitelist, and use FindPartsInRegion3WithWhiteList
with this list:
local function GetWhitelist() local Whitelist = {} for _,Plr in pairs(Game.Players:GetPlayers()) do if Plr.Character then table.insert(Whitelist,Plr.Character) end end return Whitelist end
You would then get the characters from the body parts that the Region3 picked up, and check which ones are within and without the region.
You shouldn't worry about lag for regions over large areas, they are pretty efficient and the whitelist should ignore extra parts (reducing lag from a larger number of parts). Basically, Region3s were designed for this.
However, you are also able to use Touched and TouchEnded with an invisible part. Even though exploiters can move the parts with their local scripts, if you have FilteringEnabled this change will not replicate to the server. This means that the server still sees the part in the same location and will still detect when the exploiter begins/ends touching the part. But due to the potential glitchyness of the touch events, Region3s may still be the better option.