I want to make this block function more responsive, at times it doesn’t block when you press the input for it.
Sometimes it doesn’t respond when you press right click, I think it is because of the cooldown (.3 seconds) but it makes it feel unresponsive. I would like ideas on how to show that your attacks/blocks are on cooldown or some other solution to make it feel less janky aside from reducing the cooldown as I need it to make sure the block isn’t overpowered.
-- local script parented to a tool
local function blockfunction(input, inputstate, _) -- BLOCK
-- I am using ContextActionService
if input == "Block" and inputstate == Enum.UserInputState.Begin then
if blocktrack == nil then
blocktrack = char.Humanoid:LoadAnimation(block) -- load the animation for block
end
if animating == false then -- checks if there is another animation playing
animating = true
blocktrack:Play()
action = "block"
repeat
task.wait(0.01)
--the time in which the contact frames are playing
if blocktrack.TimePosition >= 0.07 and blocktrack.TimePosition <= .75 then
contact = true -- contact says whether or not the player is doing an action
tool:WaitForChild("Blocking").change:FireServer(contact)
-- the "Blocking" object inside the tool is a Boolvalue that stores whether or not the player is blocking
-- this is used for reference in other scripts like the damage script.
else
contact = false
tool:WaitForChild("Blocking").change:FireServer(contact)
end
until blocktrack.IsPlaying == false
contact = false
-- the rest is just resetting everything so that the next action can be done.
tool:WaitForChild("Blocking").change:FireServer(contact) -- this should be false
contactable = true
action = ""
task.wait(.3)
animating = false
end
end
end