so… this is my first post on the forum, please dont judge me, so I have this… thing.
local players = game:GetService("Players")
local user_input_service = game:GetService("UserInputService")
local replicated_storage = game:GetService("ReplicatedStorage")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoid_root_part = character:WaitForChild("HumanoidRootPart")
local animator = humanoid:FindFirstChild("Animator")
local attachment = Instance.new("Attachment")
attachment.Parent = humanoid_root_part
local vector_force = Instance.new("VectorForce")
vector_force.RelativeTo = Enum.ActuatorRelativeTo.World
vector_force.Attachment0 = attachment
vector_force.ApplyAtCenterOfMass = true
vector_force.Parent = humanoid_root_part
local sword = character:WaitForChild("Sword")
local trail1 = sword:WaitForChild("NewTrail")
local trail2 = sword:WaitForChild("NewTrail2")
local slash_sound = sword:WaitForChild("SwordSlash")
local lunge_sound = sword:WaitForChild("SwordLunge")
local swing_event = replicated_storage["Remote Events"]:WaitForChild("Sword Swing")
local attack_animations = {
"rbxassetid://118711693834843",
"rbxassetid://117889044749561",
"rbxassetid://105583431456319",
"rbxassetid://79055226879618",
"rbxassetid://99658414018732"
}
local loaded_attacks = {}
for i, anim_id in ipairs(attack_animations) do
local anim = Instance.new("Animation")
anim.AnimationId = anim_id
loaded_attacks[i] = animator:LoadAnimation(anim)
end
local current_attack = 1
local attacking = false
local function enable_trails()
trail1.Enabled = true
trail2.Enabled = true
end
local function disable_trails()
trail1.Enabled = false
trail2.Enabled = false
end
local function dash()
local dash_strength = 15000
if current_attack == 5 then
dash_strength = dash_strength * 1.5
end
vector_force.Force = humanoid_root_part.CFrame.LookVector * dash_strength
task.delay(0.2, function()
vector_force.Force = Vector3.zero
end)
end
local function play_attack_sound(attack_index, animTrack)
local anim_length = animTrack.Length
if attack_index <= 4 then
slash_sound:Stop()
slash_sound:Play()
elseif attack_index == 5 then
slash_sound:Stop()
slash_sound:Play()
task.delay(slash_sound.TimeLength, function()
lunge_sound:Stop()
task.delay(0.25, function()
lunge_sound:Play()
end)
end)
end
end
local function play_next_attack()
if not attacking then return end
if humanoid:GetState() == Enum.HumanoidStateType.Freefall or humanoid:GetState() == Enum.HumanoidStateType.Jumping then
attacking = false
current_attack = 1
return
end
for _, track in pairs(loaded_attacks) do
track:Stop()
end
humanoid.JumpPower = 0
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
local animTrack = loaded_attacks[current_attack]
animTrack:Play()
print(current_attack)
enable_trails()
dash()
play_attack_sound(current_attack, animTrack)
swing_event:FireServer(current_attack)
animTrack.Stopped:Wait()
disable_trails()
current_attack = current_attack % #loaded_attacks + 1
play_next_attack()
humanoid.JumpPower = 50
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
user_input_service.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 and not attacking then
attacking = true
play_next_attack()
end
end)
user_input_service.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
attacking = false
current_attack = 1
end
end)
so whenever I wanted to start a combo, it mostly started from the second attack for some reason, and if I clicked in a middle of an animation it just skipped everything straight to the fifth attack. any suggestions???