I’ve been trying to make a combat for a really long time and i can’t get the combos to work it’ll always break and just keeps on making the current attack value 2 instead of starting back at 1 or using the wrong animation when getting to 4 using the 3rd animation instead of the one it was intended for
local module = {}
local RP = game:GetService(“ReplicatedStorage”)
local StarterPlayer = game:GetService(“StarterPlayer”)
local HitService = require(RP.Modules.HitService)
local HitBoxClass = require(RP.Modules.HitboxClass)
local HitboxTypes = require(RP.Modules.HitboxClass.Types)local MaxCombo = 4
local Last = tick()
local N = math.hugelocal function FindHumanoid(Player: Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChild(“Humanoid”)
return Humanoid
endlocal function StopAnim(Character: Model)
local Humanoid = Character:FindFirstChild(“Humanoid”)
for i,v in pairs(Humanoid.Animator:GetPlayingAnimationTracks()) do
if v.Name ~= “Idle” and v.Name ~= “Animaiton” then
v:Stop()
end
end
endlocal function ChangeCombo(Character: Model)
local CurrentAttacks = Character:FindFirstChild(“Values”):FindFirstChild(“CurrentAttacks”)Last = tick()
if CurrentAttacks.Value == 4 then
CurrentAttacks.Value = 1
else
CurrentAttacks.Value += 1
end
endlocal function GetAnim(Character:Model, AnimationName)
local CurrentAttacks = Character:FindFirstChild(“Values”):FindFirstChild(“CurrentAttacks”)
local CurrentAnim = RP.Animations.HeroicDragon.M1[“Attack”…CurrentAttacks.Value]
return CurrentAnim
endfunction module.Start(Player: Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = FindHumanoid(Player)
local RootPart = Character:FindFirstChild(“HumanoidRootPart”)
local RootParts = Character.PrimaryPart
local Animator = Humanoid:FindFirstChild(“Animator”)local Values = Character:FindFirstChild(“Values”)
local CurrentAttacks = Values:FindFirstChild(“CurrentAttacks”)
local Swinging = Values:FindFirstChild(“Swinging”)
local Attacking = Values:FindFirstChild(“Attacking”)
local Animation = Animator:LoadAnimation(GetAnim(Character, CurrentAttacks.Value))local hitboxParams = {
SizeOrPart = Vector3.new(5.5,6,6,8),
Blacklist = {Character},
DebounceTime = 1,
InitialPosition = RootPart.CFrame + RootPart.CFrame.LookVector,
VelocityPrediction = true,
Debug = true,
} :: HitboxTypes.HitboxParamslocal HitBox, connected = HitBoxClass.new(hitboxParams)
HitBox:WeldTo(RootPart, CFrame.new(0,0,-4))
HitBox:SetVelocityPrediction(false)HitBox.HitSomeone:Connect(function(HitChars)
for _, v in HitChars do
if v and v.Parent then
local HUM = v:FindFirstChildOfClass(“Humanoid”)
if HUM then
local Tif v:IsA("Model") then T = v.PrimaryPart.Position else v:IsA("BasePart") T = v.Position end if T then local LV = Instance.new("LinearVelocity", RootPart) local Attachment0 = Instance.new("Attachment", RootPart) LV.ForceLimitMode = Enum.ForceLimitMode.PerAxis LV.MaxForce = math.huge LV.Attachment0 = Attachment0 LV.VectorVelocity = (RootPart.Position - T).Unit * N game.Debris:AddItem(LV,0.2) game.Debris:AddItem(Attachment0,0.2) end if CurrentAttacks.Value >= MaxCombo then HitService.Hit(HUM,5/2,0.7,RootPart.CFrame.LookVector*20,nil) else HitService.Hit(HUM,5/2,0.7,RootPart.CFrame.LookVector*5,nil) end end end endend)
if tick() - Last > 1 then
CurrentAttacks.Value = 1
endif Attacking.Value == true then return end
Swinging.Value = true
Attacking.Value = trueStopAnim(Character)
Animation:Play()
ChangeCombo(Character)Humanoid.WalkSpeed = 1
Humanoid.JumpHeight = 0Animation:GetMarkerReachedSignal(“HitStart”):Connect(function()
HitBox:Start()
end)Animation:GetMarkerReachedSignal(“HitEnd”):Connect(function()
HitBox:Destroy()Swinging.Value = false if CurrentAttacks.Value == MaxCombo then task.wait(.7) else task.wait(.1) end Attacking.Value = falseend)
Animation.Stopped:Connect(function()
HitBox:Destroy()if Swinging.Value ~= true then Humanoid.WalkSpeed = StarterPlayer.CharacterWalkSpeed Humanoid.JumpHeight = StarterPlayer.CharacterJumpHeight endend)
end
return module