--Combat
local m1 = humanoid.Animator:LoadAnimation(game.ReplicatedStorage.SwordAnims.m1)
m1.Priority = Enum.AnimationPriority.Action
local m2 = humanoid.Animator:LoadAnimation(game.ReplicatedStorage.SwordAnims.m2)
m2.Priority = Enum.AnimationPriority.Action
local m3 = humanoid.Animator:LoadAnimation(game.ReplicatedStorage.SwordAnims.m3)
m3.Priority = Enum.AnimationPriority.Action
local combo = 1
function hitbox()
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Massless = true
hitbox.Anchored = false
hitbox.CFrame = blade.CFrame
hitbox.Color = Color3.new(3, 0, 0)
hitbox.Material = Enum.Material.Wood
hitbox.Transparency = 0.5
hitbox.Size = Vector3.new(2, 6, 2)
local weld = Instance.new("WeldConstraint")
weld.Parent = hitbox
weld.Part0 = hitbox
weld.Part1 = blade
game.Debris:AddItem(hitbox, 0.7)
--fire to server!
hitbox.Touched:Connect(function(hit)
game.ReplicatedStorage.swordEvent:FireServer(hit)
end)
end
local db = true -- debounce variable
local debounceTime = 0.6 -- seconds
tool.Activated:Connect(function()
if not db then return end
db = false
delay(debounceTime, function()
db = true
end)
if combo == 3 then
hitbox()
m3:Play()
sound1:Play()
print("Third M1")
wait(1)
combo = 1
elseif combo == 2 then
hitbox()
m2:Play()
sound1:Play()
print("Second M1")
combo = combo + 1
elseif combo == 1 then
hitbox()
m1:Play()
print("First M1")
sound1:Play()
combo = combo + 1
end
end)