✓ Accepted answer
I suggest you use Region3 to check who currently on the hill.
local charTable = {}
local inHillRegion = {}
local zone = workspace:FindFirstChild("Capture").Capture
local pos1 = zone.Position - (zone.Size/2)
local pos2 = zone.Position + (zone.Size/2)
local region = Region3.new(pos1,pos2)
while wait() do
inHillRegion = nil
local partsInRegion = workspace:FindPartsInRegion3(region,charTable,1000)
for i,v in pairs(partsInRegion)do
local thisChar = v.Parent
local player = game.Players:GetPlayerFromCharacter(thisChar)
if inHillRegion[player.UserId] = nil then
inHillRegion[player.UserId] = thisChar
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
charTable[player.UserId] = char
end)
player.CharacterRemoving:Connect(function()
charTable[player.UserId] = nil
end)
end)
I havent tested this but it might work
Edit* if you still need it, heres the working script. Make sure you put it in the capture zone part
local inHillRegion = {}
local zone = script.Parent
local pos1 = zone.Position - (zone.Size/2)
local pos2 = zone.Position + (zone.Size/2)
local region = Region3.new(pos1,pos2)
while wait(.5) do
inHillRegion = {}
local partsInRegion = workspace:FindPartsInRegion3(region,nil,500)
for i,v in pairs(partsInRegion)do
if v.Parent:FindFirstChild("HumanoidRootPart") and v.Parent:FindFirstChild("Humanoid") and v.Parent:FindFirstChild("Head") then
local player = game.Players:GetPlayerFromCharacter(v.Parent)
if inHillRegion[player.UserId] == nil then
inHillRegion[player.UserId] = v.Parent
end
end
end
for i,v in pairs(inHillRegion)do
end
end
2 comments
Checking it now.
Forgot to add that you should make the while loop wait a bit longer before repeating