-
What do you want to achieve? Keep it simple and clear!
When you press F, you will be able to block, and when you let go of F, it will stop blocking. -
What is the issue? Include screenshots / videos if possible!
The function below is successfully recieving when F is pressed and let go like it is supposed to. When you press F, it will create a BoolValue under the player’s workspace model (and it works), and then the function will use that to detect if the player is currently blocking. When you let go of F, the BoolValue then destroys itself (as it should), but the animation keeps playing.
The function (inside of a ModuleScript):
local blockdb = false
function cSet:Block(plr, animator, prevWS)
if blockdb == false then
blockdb = true
print("Block Request Recieved")
local blockAnimation
blockAnimation = animator:LoadAnimation(game.ReplicatedStorage.Combat.Animations.Block["1"])
print("Anim Loaded. ", blockAnimation.Name)
if plr:FindFirstChild("Block") == nil then
print("Block Not Found, Creating In ", plr.Name)
local block = Instance.new("BoolValue")
block.Name = "Block"
block.Parent = plr
print("Block: ", block.Name)
else
print("Destroying Block In ", plr.Name)
plr.Block:Destroy()
end
if plr:FindFirstChild("Block") ~= nil then
print("Block Found, setting Block Animation Priority To Action4 and Playing")
print("Block Animation: ", blockAnimation.Name)
blockAnimation.Priority = Enum.AnimationPriority.Action4
blockAnimation:Play()
else
print("Block Not Found, Assuming Stop Block, Stopping Anim")
blockAnimation:Stop()
task.wait(cSet.DashCooldown)
end
blockdb = false
end
end
Video w/ Outputs:
When F is pressed:
When F is released:
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked on a few forums and used :Stop(), :Pause() and :Destroy() as well as trying a couple of other things, however, none of them have worked.