I’m a bit newer on the scripting side. I recently made a system with region3 that when a player steps on a part they are given money. I then learned it was deprecated and I also learned about OverlapParams. I made a script using it and then I realized I’m stuck on something (kind of) important.
I am trying to make it so when 2 or more players are standing in the same zone it is contested.
Here is the script so far…
local territory = game.Workspace.Territory
-- parameters for hit detections
local filterObjects = {"Handle,"}
local maxObjectsAllowed = 1000
local params = OverlapParams.new(OverlapParams.new(filterObjects,Enum.RaycastFilterType.Blacklist,maxObjectsAllowed,"Default"))
-- parameters for hit detections
function ZoneSystem()
local objectsInSpace = workspace:GetPartsInPart(territory,params) -- gets parts in territory and puts it into a table
for i, v in pairs(objectsInSpace) do -- goes through the objectsInSpace table
task.wait(1)
if objectsInSpace[i].Parent:FindFirstChild("Humanoid") ~= nil then -- if its a human
local char = objectsInSpace[i].Parent:FindFirstChild("Humanoid").Parent
print(char)
end
end
end
while true do
task.wait(1)
ZoneSystem()
end
I think my main question is if there is any ideas on how I can add a contest system inside my zone system function? I was thinking of something along the lines of finding if there is more then one humanoid in the zone, but I couldn’t quite figure out how I would get that to work…
Also is there any way to improve the efficiency of my code or what I have written already? Looking for any tips as I am still learning.