#How do I make hitboxes not spam hit and instead hits after the player leaves the hitbox and re-enter
1 messages · Page 1 of 1 (latest)
local size = Vector3.new(21.475, 1, 9.435)
local HitboxPart = Instance.new("Part")
HitboxPart.Anchored = true
HitboxPart.CanQuery = false
HitboxPart.CanCollide = false
HitboxPart.CFrame = CFpos
HitboxPart.Transparency = 0.5
HitboxPart.Size = size
HitboxPart.Parent = workspace
local params = OverlapParams.new(workspace.TestWall)
params.FilterDescendantsInstances = {workspace.TestWall}
while task.wait() do
local parts = workspace:GetPartBoundsInBox(CFpos, size, params)
local Hit = {}
for i, part in pairs(parts) do
if part.Parent:WaitForChild("Humanoid", 0.1) or part.Parent.Parent:WaitForChild("Humanoid") then
if part.Name == "visibleHitbox" and not table.find(Hit, part.Parent) then
local char = part.Parent
print(char)
table.insert(Hit, char)
params:AddToFilter(Hit)
end
end
end
end```