This is probably my first time ever making an actual proper blocking system and the problem I’m having is the animation does not stop when the event is fired again with the bool false. But the NoRun and Blocking Values are destroyed from the players character but no animation is played? Why is that. Code is below. Also, how do people implement with tick a cd to prevent block spamming? so if the player had “Attacking” in his Character an x amt of seconds ago he cant block
EDIT: Thought abt the x amt of thing and thoughtr I should make a value that updates the seconds/holds the time an attack was thrown
Code: (Sorry for a super long question)
BlockingEvent.OnServerEvent:Connect(function(Player, Action, Type, Bool)
local toolName = Character:FindFirstChildOfClass("Tool") and Character:FindFirstChildOfClass("Tool").Name
local blockAnim = Humanoid:LoadAnimation(AnimsFolder:FindFirstChild(toolName).Block)
if Action then
if Type == "Magic" then
if Bool == true then
mBlock(Character)
-- Handle magic blocking value
-- e.g., Player.MagicBlockingValue = 10
else
Player.Character.NoRun:Destroy()
Player.Character.ShieldBlocking:Destroy()
-- Handle magic blocking value reset or cleanup
-- e.g., Player.MagicBlockingValue = 0
end
elseif Type ~= "Magic" and Bool == true then
blockAnim:Play()
Block(Character)
-- Handle regular blocking value
-- e.g., Player.RegularBlockingValue = 5
elseif Bool == false then
blockAnim:Stop()
Player.Character.NoRun:Destroy()
Player.Character.Blocking:Destroy()
-- Handle any other necessary cleanup for normal blocking
end
end
end)