here is the server script, let me know if u need the local script ( u probably dont need that becuz its just hitbox and animation based )
server script:
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")
function newHitbox(character, size, offset, damage, linger)
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp == nil then return end
local weld = Instance.new("WeldConstraint", hrp)
local hitbox = Instance.new("Part")
weld.Part0 = hrp
weld.Part1 = hitbox
hitbox.Transparency = 1
hitbox.CanCollide = false
hitbox.CanQuery = false
hitbox.Massless = true
hitbox.Size = size
hitbox.CFrame = hrp.CFrame + hrp.CFrame.LookVector * offset.X + Vector3.new(0,offset.Y)
hitbox.Parent = character
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") == nil then return end
for _, v in pairs(hitbox:GetChildren()) do
if v:IsA("ObjectValue") then
if v.Value == hit.Parent then return end
end
end
local hitCounter = Instance.new("ObjectValue", hitbox)
hitCounter.Value = hit.Parent
hit.Parent.Humanoid:TakeDamage(damage)
local sound = script.Sound:Clone()
sound.Parent = hit.Parent:FindFirstChild("Humanoid")
sound:Play()
game.Debris:AddItem(sound,2)
local punchParticle = game.ReplicatedStorage["Particle"].Attachment:Clone()
punchParticle.Parent = hit.Parent:FindFirstChild("HumanoidRootPart")
for i, v in pairs(punchParticle:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Emit(30)
game.Debris:AddItem(punchParticle,0.4)
end
end
end)
game.Debris:AddItem(hitbox, linger)
end
hitboxEvent.OnServerEvent:Connect(function(plr, size, offset, damage, linger)
newHitbox(plr.Character, size, offset, damage, linger)
end)