local UserInputService = game:GetService("UserInputService")
local hold
local Character
local Humanoid
local CanAttackKBM
local OldMousePositionX = 0
local OldMousePositionY = 0
local Equipped = false
local SwordSwingDirection = ""
local OldDirection = ""
local AnimDebounce = false
local Ready = "Ready"
script.Parent.Equipped:connect(function(mouse)
Character = script.Parent.Parent
Humanoid = Character.Humanoid
Attack1 = Humanoid:LoadAnimation(script:WaitForChild("Attack1"))
Attack1.Priority = Enum.AnimationPriority.Action
Attack1Finish = Humanoid:LoadAnimation(script:WaitForChild("Attack1Finish"))
Attack2 = Humanoid:LoadAnimation(script:WaitForChild("Attack2"))
Attack2.Priority = Enum.AnimationPriority.Action
Attack2Finish = Humanoid:LoadAnimation(script:WaitForChild("Attack2Finish"))
Attack3 = Humanoid:LoadAnimation(script:WaitForChild("Attack3"))
Attack3.Priority = Enum.AnimationPriority.Action
Attack3.Looped = false
Attack3Finish = Humanoid:LoadAnimation(script:WaitForChild("Attack3Finish"))
Attack4 = Humanoid:LoadAnimation(script:WaitForChild("Attack4"))
Attack4.Priority = Enum.AnimationPriority.Action
Attack4.Looped = false
Attack4Finish = Humanoid:LoadAnimation(script:WaitForChild("Attack4Finish"))
Blocking = Humanoid:LoadAnimation(script:WaitForChild("Blocking"))
Holding = Humanoid:LoadAnimation(script:WaitForChild("Holding"))
Equipped = true
Holding:Play()
end)
script.Parent.Unequipped:Connect(function()
Equipped = false
Holding:Stop()
end)
UserInputService.InputBegan:Connect(function(input)
local InputType = input.UserInputType
if InputType == Enum.UserInputType.MouseButton1 and Equipped and not AnimDebounce and Ready == "Ready" then
Holding:Stop()
print(Ready)
print("Playing animation")
if SwordSwingDirection == "Left" then
OldDirection = "Left"
Attack2:Play()
elseif SwordSwingDirection == "Right" then
OldDirection = "Right"
Attack4:Play()
elseif SwordSwingDirection == "Up" then
OldDirection = "Up"
Attack1:Play()
elseif SwordSwingDirection == "Down" then
OldDirection = "Down"
Attack3:Play()
end
AnimDebounce = true
end
end)
UserInputService.InputEnded:Connect(function(input)
local InputType = input.UserInputType
if InputType == Enum.UserInputType.MouseButton1 and Equipped and AnimDebounce and Ready == "Ready" then
Holding:Stop()
print(OldDirection)
if OldDirection == "Up" then
Attack1Finish:Play()
Ready = "Is Playing"
task.wait(Attack1Finish.Length/Attack1Finish.Speed)
Attack1Finish:Stop()
Attack1:Stop()
Holding:Play()
task.wait(1)
Ready = "Ready"
elseif OldDirection == "Left" then
Attack4Finish:Play()
Ready = "Is Playing"
task.wait(Attack4Finish.Length/Attack4Finish.Speed)
Attack4Finish:Stop()
Attack4:Stop()
Holding:Play()
task.wait(1)
Ready = "Ready"
elseif OldDirection == "Down" then
Attack3Finish:Play()
Ready = "Is Playing"
task.wait(Attack3Finish.Length/Attack3Finish.Speed)
Attack3Finish:Stop()
Attack3:Stop()
Holding:Play()
task.wait(1)
Ready = "Ready"
elseif OldDirection == "Right" then
Attack2Finish:Play()
Ready = "Is Playing"
task.wait(Attack2Finish.Length/Attack2Finish.Speed)
Attack2Finish:Stop()
Attack2:Stop()
Holding:Play()
print("Playing and stopping")
task.wait(1)
Ready = "Ready"
end
print(Attack1.Priority)
print(Attack2.Priority)
print(Attack3.Priority)
print(Attack4.Priority)
print(Attack1.Looped)
print(Attack2.Looped)
print(Attack3.Looped)
print(Attack4.Looped)
print(Attack1.IsPlaying)
print(Attack2.IsPlaying)
print(Attack3.IsPlaying)
print(Attack4.IsPlaying)
Attack2:Stop()
Attack1:Stop()
Attack3:Stop()
Attack4:Stop()
--Holding:Play()
AnimDebounce = false
end
end)
UserInputService.InputChanged:Connect(function(input, engine_processed)
if Equipped then
if input.UserInputType == Enum.UserInputType.MouseMovement then
if OldMousePositionX > input.Position.X then
SwordSwingDirection = "Right"
elseif OldMousePositionX < input.Position.X then
SwordSwingDirection = "Left"
end
if OldMousePositionY > input.Position.Y then
SwordSwingDirection = "Up"
elseif OldMousePositionY < input.Position.Y then
SwordSwingDirection = "Down"
end
OldMousePositionX = input.Position.X
OldMousePositionY = input.Position.Y
end
end
end)
pls help I am trying to fix this since 3 days I can’t find anyone help me, I have 4 animations of initial movment and 4 animation finish movements
Why the 2nd and 4th Attack animations plays randomly regardless of Stop()?
I tried later putting if statement inside right then it printed out “Playing and stopping” so it should have stopped why would it play again after finishing the attack4finish animation? it is not even looping idk what is the issue