How to cancel a skill/ability when player gets hit during the skill

So basically, let’s say you use an ability but you get hit in the process (not before or after, right in between of using the skill). I tried using :Disconnect, disabling and reenabling the script (but scripts dont work after enabled and disabling. Most likely cuz of my PlayerAdded thingy). So if someone could give some advice, that would be great.

2 Likes

set your :Connect function under a variable

local connection = (Event:Connect(function()

end))

connection:Disconnect()

Can I disconnect the function inside the function?

yeah, you have to create the variable beforehand though. it would look something like:

local connection

connection = event:Connect(function()
connection:Disconnect()
end)
1 Like