You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I used getBoundInBox in my sword I want it to detect the zombie and find Humanoid and takedamage
What is the issue? Include screenshots / videos if possible!
I printed workspace:GetPartBoundsInBox(hitbox.CFrame, hitbox.Size, overlapsParam)
but it printed the body part of the zombie instead of the zombie’s name
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I searched for some tutorials to confirm my understanding but no one made any…
local filter = OverlapParams.new()
filter.FilterDescendantsInstances = {workspace.zombiesFolder}
filter.FilterType = Enum.RaycastFilterType.Whitelist
debounce = false
tool.Activated:Connect(function()
if debounce == false then
print("activated")
debounce = true
--slashAnim:Play()
local zombie = workspace:GetPartBoundsInBox(hitbox.CFrame, hitbox.Size, filter)
print(zombie)
There are probably better ways of doing this but you can loop inside the table that GetPartBoundsInBox returns and check if the values are parented to the zombie.
local zombieName = "zombie"
local filter = OverlapParams.new()
filter.FilterDescendantsInstances = {workspace.zombiesFolder}
filter.FilterType = Enum.RaycastFilterType.Whitelist
debounce = false
tool.Activated:Connect(function()
if debounce == false then
print("Activated")
debounce = true
--slashAnim:Play()
local Table = workspace:GetPartBoundsInBox(hitbox.CFrame, hitbox.Size, filter)
for _, v in pairs(Table) do
if v.Parent and v.Parent.Name:lower() == zombieName then print(true) break end
end
end
end)
yea I did kinda similar to what you said here
so I made a folder and put zombie then detect the zombie’s bodypart that hit.
then check if bodypart.parent.parent (bodypart.parent.parent is the zombie folder)
== folder or not. if yes then bodypart.parent (the zombie).Humanoid:TakeDamge
here final code
local DAMAGE = 50
--local slashAnim = humanoid:LoadAnimation(slash)
local filter = OverlapParams.new()
filter.FilterDescendantsInstances = {workspace.zombiesFolder}
filter.FilterType = Enum.RaycastFilterType.Whitelist
debounce = false
tool.Activated:Connect(function()
if debounce == false then
print("activated")
debounce = true
--slashAnim:Play()
local zombie = workspace:GetPartBoundsInBox(hitbox.CFrame, hitbox.Size, filter)
print(zombie)
for i, bodyPart in pairs(zombie) do
if bodyPart.Parent.Parent == workspace.zombiesFolder then
bodyPart.Parent:FindFirstChild("Humanoid"):TakeDamage(DAMAGE)
end
end
wait(.5)
debounce = false
end
end)