Hello, I’m trying to make a king of the hill script. If there is one player on the hill, he gets the winner value. If there are multiple people, the hill is conflicted. I have finished the part where the player gets added into the table when he is inside the region3 area. However I don’t know how to remove the player from the table when he is outside the region3. I found some research on king of the hill scripts but not with a region3.
script.
local zone = game.Workspace.Turf:WaitForChild("TurfPoint")
local pos1 = zone.Position - (zone.Size/2)
local pos2 = zone.Position + (zone.Size/2)
local region = Region3.new(pos1,pos2)
local leader = zone:WaitForChild("Leader")
local inHill = {}
while true do wait(0.1)
print(#inHill) --printing the numbers inside the Inhill table
local partsInRegion = workspace:FindPartsInRegion3(region,nil,1000)
for _, part in pairs(partsInRegion) do
if #inHill == 0 and part.Parent:FindFirstChild("Humanoid") then --add the player, because for some reason if there is nothing inside a table, you cant loop through it
table.insert(inHill,part.Parent) --inserting the player into the table
end
for _, plrs in pairs(inHill) do --looping through the Inhill table to check if the player is already in the table or not, if not, add him.
if part.Parent:FindFirstChild("Humanoid") and part.Parent ~= plrs then --player is not in the table, so add him.
table.insert(inHill,part.Parent)
else
print(part.Parent.Name.." is already in the inhill table!")
end
end
end
end