So I have this script that calls a function using :GetPartBoundsInBox() to return the table. I have it check if the table is empty, but I cant figure out why it isn’t returning from the if statement.
params=OverlapParams.new()
params.FilterDescendantsInstances=CloneMachine:GetDescendants()
function checkHitbox()
return workspace:GetPartBoundsInBox(
CFrame.new(-222.777,108.299,-894.081),
Vector3.new(4.72,5.599,4.64),
params
)
end
runPrompt.Triggered:Connect(function(player)
local entranceHitbox=checkHitbox()
print(entranceHitbox)
if entranceHitbox=={} then print("THERE IS NOTHING IN THE BOXX") return else
for i,instance in entranceHitbox do
print(instance,instance.Parent)
end
end
end)
i’d suggest just using a for loop instead of that complicated thing
local box = workspace:GetPartBoundsInBox(cframe, size)
local table = {}
for _,v in box do
if v.Parent then
table.insert(table, v.Parent)
print(table)
end
end
-- print({} == {}) This will always print false because tables compare to their memory address
-- more like: print(0x7baf203485bc2016 == 0x46d6d40c59da7666)
if #entranceHitbox == 0 then
print("empty")
return
end
for i, instance in entranceHitbox do
print(instance, instance.Parent)
end