Hi, I’ve been trying to test out with GetPartsBoundInBoxes, but when I use this code to try to detect the character instead of the individual parts inside of the box, it instead timeouts the script.
I’ve tried changing the time the script waits until it prints, but either way it times it out. What do I do?
local cf = CFrame.new(20, 8, 0)
local size = Vector3.new(10, 10, 10)
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.CanQuery = false
part.CanTouch = false
part.CFrame = cf
part.Size = size
part.Transparency = 0.5
part.Parent = game.Workspace
while true do
local parts = game.Workspace:GetPartBoundsInBox(cf, size)
local hitCharacters = {}
for i, part in pairs(parts) do
if part.Parent:FindFirstChildOfClass("Humanoid") and not table.find(hitCharacters, part.parent) then
table.insert(hitCharacters, part.Parent)
end
print(hitCharacters)
wait(0.5)
end
end