#getpartboundinbox not working

1 messages · Page 1 of 1 (latest)

uneven furnace
#

local char = script.Parent
local mobs = workspace.mobs
local hrp = char:WaitForChild("HumanoidRootPart")
local mobchildren = mobs:GetChildren()

local function getmobinrange()

local rangesize = Vector3.new(6, 6, 9)

local range = Instance.new("Part")

range.Anchored = true
range.CanCollide = false
range.CanQuery = true
range.CanTouch = false
range.Size = rangesize
range.CFrame = script.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(0, 0, -2.5))
range.BrickColor = BrickColor.new("Black")
range.Transparency = 0.75  --hitbox bs remember to change
range.Parent = script.Parent

local weld = Instance.new("WeldConstraint")
weld.Part0 = range
weld.Part1 = hrp
weld.Parent = range

--local params = OverlapParams.new()
--params.FilterType = Enum.RaycastFilterType.Include
--params.FilterDescendantsInstances = {mobchildren}

while true do
    wait()
    local towercframe = script.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(0, 0, -2.5))
    range.CFrame = towercframe
    local somethingtouchedrange = workspace:GetPartBoundsInBox(towercframe, rangesize)

    print(somethingtouchedrange)
end

end

getmobinrange()

#

it kept printing {...}

fallen portal
#

Use OverlapParams with FilterType = Include and pass mobs:GetChildren() to GetPartBoundsInBox() this filters the results to only mob parts. Without it, it returns everything nearby

uneven furnace
#

wha

uneven furnace
# fallen portal

local char = script.Parent
local mobs = workspace.mobs
local hrp = char:WaitForChild("HumanoidRootPart")

local function getmobinrange()

local rangesize = Vector3.new(6, 6, 9)

local range = Instance.new("Part")

range.Anchored = true
range.CanCollide = false
range.CanQuery = true
range.CanTouch = false
range.Size = rangesize
range.CFrame = script.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(0, 0, -2.5))
range.BrickColor = BrickColor.new("Black")
range.Transparency = 0.75  --hitbox bs remember to change
range.Parent = script.Parent

local weld = Instance.new("WeldConstraint")
weld.Part0 = range
weld.Part1 = hrp
weld.Parent = range

local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Include
params.FilterDescendantsInstances = mobs:GetChildren()
params.RespectCanCollide = false

while true do
    wait()
    local towercframe = script.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(0, 0, -2.5))
    range.CFrame = towercframe
    local somethingtouchedrange = workspace:GetPartBoundsInBox(towercframe, rangesize, params)
    
    
    print(somethingtouchedrange)
    for _, part in pairs(somethingtouchedrange) do
        print(part:GetFullName())
    end
end

end

getmobinrange()

this my version inspired by yours but it still doesnt work

hollow iglooBOT
#

studio** You are now Level 7! **studio

uneven furnace
#

it now prints {}

fallen portal
#

You need to collect all the parts inside each mob model and use those in FilterDescendantsInstances for GetPartBoundsInBox to detect them

uneven furnace
#

how?

fallen portal
#

You see this line?
params.FilterDescendantsInstances = mobs:GetChildren() This gives parts, models, or folders inside mobs If your enemies are Models, GetChildren() won’t return the individual parts inside them, which is what GetPartBoundsInBox() checks for

uneven furnace
#

so i use getdescendants

#

?

fallen portal
#
local char = script.Parent
local mobs = workspace:WaitForChild("mobs")
local hrp = char:WaitForChild("HumanoidRootPart")

local function getmobinrange()
    local rangesize = Vector3.new(6, 6, 9)

    local range = Instance.new("Part")
    range.Anchored = true
    range.CanCollide = false
    range.CanQuery = true
    range.CanTouch = false
    range.Size = rangesize
    range.CFrame = hrp.CFrame * CFrame.new(0, 0, -2.5)
    range.BrickColor = BrickColor.new("Black")
    range.Transparency = 0.75
    range.Parent = char

    local weld = Instance.new("WeldConstraint")
    weld.Part0 = range
    weld.Part1 = hrp
    weld.Parent = range

    local allMobParts = {}
    for _, mob in pairs(mobs:GetChildren()) do
        for _, part in pairs(mob:GetDescendants()) do
            if part:IsA("BasePart") then
                table.insert(allMobParts, part)
            end
        end
    end

    local params = OverlapParams.new()
    params.FilterType = Enum.RaycastFilterType.Include
    params.FilterDescendantsInstances = allMobParts
    params.RespectCanCollide = false

    while true do
        task.wait()
        local towercframe = hrp.CFrame * CFrame.new(0, 0, -2.5)
        range.CFrame = towercframe
        local results = workspace:GetPartBoundsInBox(towercframe, rangesize, params)

        for _, part in pairs(results) do
            print("Hit:", part:GetFullName())
        end
    end
end

getmobinrange()
uneven furnace
#

ill js copy paste ur scripts inside to see if it works

#

now it dont even print anything

fallen portal
#

If you want I can look further into this dms but im not trying to spend too much time on it. Maybe you can just give me access as an editor to your game file

hollow iglooBOT
#

studio** You are now Level 2! **studio

uneven furnace
#

i removed the params and it still prints {}

fallen portal
#

Make sure the mobs have psychical parts

uneven furnace
#

physical parts?

fallen portal
#

BasePart (like Part, MeshPart, or HumanoidRootPart)

uneven furnace
#

yeah i think it is cause i use rigbuilder to import it

fallen portal
#

possibly

#

I dont know how else to help you without further details on what you have so far

#

sorry 😦