What do you want to achieve?
I want my player to not be able to attack while a the parry animation is played animation is being played
What is the issue?
The issue is that I don’t know how I am able to achieve this.
What solutions have you tried so far?
I have tried adding an cooldown to the cooldown variable but didn’t work.
Here is the code if needed:
-- PLAY ANIMATIONS --
tool.Activated:Connect(function()
if not debounce then
debounce = true
if combo == 0 then
one:FireServer()
playAnim(script:WaitForChild("Attack1"))
task.wait(cooldown)
combo = 1
elseif combo == 1 then
two:FireServer()
playAnim(script:WaitForChild("Attack2"))
task.wait(cooldown)
combo = 2
else
combo = 0
end
wait(0.75)
debounce = false
end
-- PLAY ANIMATION WHEN PARRIED --
parryEvent.OnClientEvent:Connect(function()
playAnim(script:WaitForChild("Parried"))
end)
end)
Any help is appreciated.
You could just set debounce to true while the animation is playing, then set it to false when it stops.
debounce = true
playAnim(script:WaitForChild("Parried"))
task.wait(1) -- or however long your wait is
debounce = false
If you’re really anxious about overlap however, you could just make it another variable that acts like debounce (something like parryStun).
1 Like
I apologize, but what I meant to say is that during the parry animation you are not able to do an attack.
In red example, you can put a wait time of the animations length. The debounce tells you that tou cannot attack until the parry animation is complete.
Why not create an attribute within the player, or player’s character as such:
player:SetAttribute("Parried", false)
Then once the player gets parried ( done on the server ) you can set the attribute to true as such:
player:SetAttribute("Parried", true)
And once the parry is complete ( on the server ) then you just set the attribute to false
.
And to make sure the player can’t attack while they’re parried you can edit the .Activated
function of the tool to something like this:
tool.Activated:Connect(function()
if (player:GetAttribute("Parried")) then
return
end
end)
Hope this helps