So, in a sword fighting game I'm making, I was working on a stun script. The stun script worked (Almost) perfectly, it would work by anchoring the player when a number value went below 9. (It started at 21, and when the player got hit, it would decrease by 3 every time) The problem was, it didn't stop the player from using a tool to hit, or block incoming attacks. (That is what the sword can do) I need help finding a way to stop that from happening. I thought about disabling the tool if you equip it, but I can't quite figure that out. I would like for someone to find out how I could go about disabling the tool when your stunned, By the way, if you looked at my last post on this topic, I have changed some things (Put the number value in the player, Changed the stun value from 7 to 9.) Thanks in advance.
Code For Reference
local hum = script.Parent.Parent.Humanoid local humRootPart = script.Parent.Parent.HumanoidRootPart local buildup = script.Parent stunned = false buildup.Changed:Connect(function(newValue) if newValue <= 9 then if stunned == false then stunned = true print("epic") local StunAnim = hum:LoadAnimation(script.Parent.StunAnim) StunAnim:Play() humRootPart.Anchored = true if stunned == true then wait(4.5) stunned = false StunAnim:Stop() humRootPart.Anchored = false buildup.Value = 21 end end end end)