--// HITBOX MODULE \\--

local Debris = game:GetService("Debris")

local hitbox = {}
hitbox.__index = hitbox

-- Default properties
hitbox.Visualize = false
hitbox.Size = Vector3.new(1, 1, 1)
hitbox.Position = Vector3.new(0, 0, 0)
hitbox.Offset = Vector3.new(0, 0, 0)
hitbox.Damage = 0

function hitbox.new()
    local self = setmetatable({}, hitbox)
    return self
end

function hitbox.create()
    -- Ensure Hitboxes folder exists
    local hitboxesFolder = workspace:FindFirstChild("Hitboxes")
    if not hitboxesFolder then
        hitboxesFolder = Instance.new("Folder")
        hitboxesFolder.Name = "Hitboxes"
        hitboxesFolder.Parent = workspace
    end

    -- Create a new Part
    local part = Instance.new("Part")
    part.Parent = hitboxesFolder
    part.Name = "Hitbox"
    part.CanCollide = false
    part.Anchored = true
    part.Size = self.Size
    part.Position = self.Position + self.Offset
    
    -- Set transparency based on the Visualize property
    part.Transparency = self.Visualize and 0.6 or 1

    -- Optional: Automatically clean up the part
    Debris:AddItem(part, 0.1)
    
    -- Handle collisions
    part.Touched:Connect(function(obj)
        local char = obj.Parent
        
        if self.Damage and self.Damage > 0 and char and char:FindFirstChildOfClass("Humanoid") then
            local humanoid = char:FindFirstChildOfClass("Humanoid")
            humanoid:TakeDamage(self.Damage)
        end
    end)
end

return hitbox

-- Combat Server

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Remotes = ReplicatedStorage:FindFirstChild("Remotes")
local Modules = ReplicatedStorage:FindFirstChild("Modules")

local CombatRemote = Remotes:FindFirstChild("CombatRemote")

local jrrHitbox = require(Modules:FindFirstChild("jrrHitbox"))

local lastHit = tick()

local combo
local MAX_COMBO = 4

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        char:SetAttribute("Combo", 1)
    end)
end)

local function GetCombo(char)
    combo = char:GetAttribute("Combo")

    local player = game.Players:GetPlayerFromCharacter(char)
    
    if lastHit[player] > 1.25 then
        char:SetAttribute("Combo", 1)
    end
    
    if not combo then
        warn("no combo attribute found")
        return
    end
    
    
end

local function getAnimation(anim, jump)
    
    return anim
end

CombatRemote.OnServerEvent:Connect(function(player)
    local char = player.Character
    if not char then return end

    local HumanoidRootPart = char:FindFirstChild("HumanoidRootPart")
    if not HumanoidRootPart then return end

    -- Create and configure hitbox
    local part = jrrHitbox.create()
    part.Position = HumanoidRootPart.Position
    part.Offset = Vector3.new(0, 0, -2.5)
    part.Size = Vector3.new(3, 3, 3)
    part.Visualize = true
end)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: