I’m trying to make some hitbox detection but I’m unable to figure out a way to detect the collision correctly, .Touched wont work because of its funky system, it only really detects when you move in it, GetTouchingParts() wont work because my hitbox is non-collidable, i don’t know what else there is. Please help!
local AU = game.ReplicatedStorage["Abillity Used"]
local TS = game:GetService("TweenService")
local List = require(game.ServerScriptService.Abilitys)
local hitboxes = game.ReplicatedStorage.Hitboxes
AU.OnServerEvent:Connect(function(player, key)
print(key == Enum.UserInputType.MouseButton1)
if key == Enum.UserInputType.MouseButton1 then
print("hi")
local dmg = List.killers.groovy.m1.dmg
local cd = 0.8
local Clones = {}
local attacked = {}
local function contains(tbl, value)
for _, v in pairs(tbl) do
if v == value then
return true
end
end
return false
end
for i = 1, 5 do
local cframe = player.Character:WaitForChild("HumanoidRootPart").CFrame
clone = hitboxes.Melee.M1:Clone()
clone.Parent = workspace
clone.CFrame = cframe
clone.CFrame = cframe * CFrame.new(0, 0, -2)
task.wait(0.01)
table.insert(Clones, clone)
end
for _, clone in pairs(Clones) do
local touchingParts = clone:GetTouchingParts()
for _, part in pairs(touchingParts) do
if part.Parent:FindFirstChild("Humanoid") then
if not contains(attacked, part.Parent) then
table.insert(attacked, part.Parent)
part.Parent.Humanoid.Health -= dmg
end
end
end
end
for idx, clone in pairs(Clones) do
wait(0.01)
clone.CanTouch = false
wait(0.18)
local tween = TS:Create(clone, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {Transparency = 1})
tween:Play()
tween.Completed:Wait()
clone:Destroy()
end
else
print("no working")
end
end)