Okay, so I made a block move in a fighting game, and it works just fine usually… However, if someone spams the key then for some reason the animation doesn’t end?
BlockScript:
local Event2ElectricBoogaloo = game.ReplicatedStorage.BlockEvent2ElectricBoogaloo
local Stunned = script.Parent.Stunned
local UsingMove = script.Parent.UsingMove
local Players = game:GetService("Players")
local Player = Players:GetPlayerFromCharacter(script.Parent)
local Blocking = script.Parent.Block
local Parrying = script.Parent.Parry
local AnimEvent = game.ReplicatedStorage.AnimEvent
local Anim = game.ReplicatedStorage.Anims.Block
local Debounce = false
local CD = 1
local function ParryTime()
Parrying.Value = true
wait(0.15)
Parrying.Value = false
end
local function OnEvent(Plr)
if Plr == Player and Stunned.Value <= 0 and not UsingMove.Value and not Blocking.Value and not Parrying.Value and not Debounce then
print(Debounce)
UsingMove.Value = true
Debounce = true
Blocking.Value = true
ParryTime()
AnimEvent:FireClient(Plr, "Start", 1, Anim)
end
end
Event.Event:Connect(OnEvent)
local function On2ndEvent(Plr)
if Plr == Player and Blocking.Value and Stunned.Value <= 0 and Debounce then
UsingMove.Value = false
Blocking.Value = false
AnimEvent:FireClient(Plr, "Stop", 1, "Block")
wait(CD)
Debounce = false
end
end
Event2ElectricBoogaloo.OnServerEvent:Connect(On2ndEvent)
AnimScript:
Player.CharacterAdded:Wait()
game.ReplicatedStorage.AnimEvent.OnClientEvent:Connect(function(WhatDo, Speed, Animation)
local Char = Player.Character
local Human = Char:WaitForChild("Humanoid")
local Animator = Human:WaitForChild("Animator")
if WhatDo == "Start" then
local Anim = Animator:LoadAnimation(Animation)
Anim:Play()
Anim:AdjustSpeed(Speed)
elseif WhatDo == "ChangeSpeed" then
local Anims = Animator:GetPlayingAnimationTracks()
local Anim = nil
for i, v in pairs(Anims) do
if v.Name == Animation then
Anim = v
end
end
if Anim then
Anim:AdjustSpeed(Speed)
end
elseif WhatDo == "Stop" then
local Anims = Animator:GetPlayingAnimationTracks()
local Anim = nil
for i, v in pairs(Anims) do
if v.Name == Animation then
Anim = v
end
end
if Anim then
Anim:Stop()
end
end
end)
Normal:
robloxapp-20221212-1035491.wmv (450.7 KB)
When mashing:
robloxapp-20221212-1036030.wmv (833.5 KB)
(for the record it keeps holding that pose even if you stop mashing)