-- \\ Player-Related Variables //--
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HUM = Character:WaitForChild("Humanoid")
-- \\ Get-Service Variables/Server-Script-Variables // --
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local SSS = game:GetService("ServerScriptService")
-- \\ Server-Script-Variables // --
local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local KeyProvider = game:GetService("KeyframeSequenceProvider")
-- \\ Cooldowns // --
local Debounce = false
local CDS = {
1,
2
}
-- \\ Anims Variables // --
local Animations = script.Parrying
local Anims = Animations.Parrying
local LoadedAnims = Character.Humanoid:LoadAnimation(Anims)
-- \\ Misc. Variables // --
local Blockin = UIS:IsKeyDown(Enum.KeyCode.F)
local CD = 10
local Missed = 15
local curr = 0
local prev = 0
local Held = UIS:IsKeyDown(Enum.KeyCode.F)
local Debounce = false
local ButtonDown = false
-- \\ Functions // --
UIS.InputBegan:Connect(function(Input, Processed)
if Processed then
return
end
if Input.UserInputType == Enum.UserInputType.MouseButton1 and Character.Humanoid:FindFirstChild("IsBlocking").Value == true then
print("LOL?")
if not Processed then
Debounce = true
ButtonDown = true
RS.Parrying:FireServer()
LoadedAnims:Play()
local curr = os.clock()
local PT = curr - prev
if PT < 0.1 then
LoadedAnims:Stop()
RS.ParryRelease:FireServer()
Character.Humanoid:FindFirstChild("Parry").Value = false
Character.Humanoid:FindFirstChild("Blocking").Value = false
print("BOOM")
ButtonDown = false
wait(CD)
Debounce = false
end
end
end
end)
UIS.InputEnded:Connect(function(input, typing)
if typing then return end
if input.KeyCode == Enum.KeyCode.F and Blockin and ButtonDown == true then
LoadedAnims:Stop()
end
end)
if Character.Humanoid:FindFirstChild("Parry").Value == false then
LoadedAnims:Stop()
end
The game is meant to be parrying, and after 0.25 seconds it’ll disable everything, but for some odd reason it won’t stop playing the block animation, and it’ll continuously play the anim.
First off, the formatting is atrocious. Secondly, you should kinda make this clear. If I asked a random person what parrying means they would probably give me a weird face.
Also, is this in a local script? Where is it located? These are all questions that should be answered in your post.
I can’t be one to judge though - my posts are trash. I’ll take a look.
Ouch, although thanks for the criticism. I’ll take that in mind the next time I make a local script, since I think a lot more about organization for a module script.
This is indeed a Local Script, and parrying is kind of like blocking if the person had a heavy stun as a downside if they hit the person in that certain timeframe. Sekiro has good examples of that.
Where is the “prev” variable being updated? You have a check that determines wether to stop playing the block animation that relies on the difference between curr and prev yet I do not see where prev is updated.
-- \\ Misc. Variables // --
local Blockin = UIS:IsKeyDown(Enum.KeyCode.F)
local CD = 10
local Missed = 15
local curr = 0
local prev = 0
local Held = UIS:IsKeyDown(Enum.KeyCode.F)
local Debounce = false
local ButtonDown = false
Tbh I don’t quite understand the flow of the parrying process you have. But seems to me that something like this would work:
local parrying = false
local function DoParry(actionName, inputState, inputObj)
if(actionName == "Parry" and inputState == Enum.UserInputState.Begin)then
if(Character.Humanoid:FindFirstChild("IsBlocking").Value)then
if(parrying)then return end --already in progress
parrying = true --Started
RS.Parrying:FireServer()
LoadedAnims:Play() --Don't loop it!
LoadedAnims.Stopped:Wait()
RS.ParryRelease:FireServer()
Character.Humanoid:FindFirstChild("Parry").Value = false
Character.Humanoid:FindFirstChild("Blocking").Value = false
task.wait(CD)--Wait cool down period
parrying = false --finished
end
end
end
--This binding could be set once block is activated? Unbind after the parry is complete?
game:GetService("ContextActionService"):BindAction("Parry", DoParry, Enum.UserInputType.MouseButton1)
Basically, you were a player the kind of flow chart I have in mind is like this:
Player1 is attacking, Player2 is blocking → At a certain timeframe, Player2 is still holding the block key [F] → They would press the Left Mouse button whilst the Block key is still being held → If it misses, the character making the attempt to parry would get punished, their F key being forcibly disabled, disabling blocking → If it does land, the character that was attacking would be dazed and unable to attack giving Player2 a chance to counter the attack.
(If this is confusing or too much just tell me and I will make only the very important part more prominent)
It sounds as if what I provided would accomplish that. When the left mouse button is pressed, the function fires, and checks that the player was blocking. If they were activates the parry. From there you just have to determine if the parry was successful or not.
Hrm. Yeah that’s a pickle. In my controllers I keep all the input controls in the same controller module. So I can adjust them based on context like this. Maybe try adding a check to the blocking script that cancels when the blocking value is set to false?