-
I do not know why there is a delay/lag at the end of knock back effect. I think it happens when Debris destroys an item after the duration ended. However, after few knockbacks everything works fine. Do I have to preload this and how would I do it
-
This is when I just join the server. https://gyazo.com/46c92a0073767a6805931d8f680cc4fe
this is after i knock npc for a few times.https://gyazo.com/f8994954e294a9e8ce8cc6bcd5a4e014 -
I tried switching back to BodyVelocity, but that did not help.
if activationCount == 2 then
warn("KNOCK BACKKK")
-- Apply knockback effect for the third activation
-- Implement your knockback logic here
local attachment = Instance.new("Attachment") --// Creating an attachment for the LinearVelocity (THIS IS IMPORTANT!)
attachment.Name = "VelocityAttachment" --// Naming it
attachment.Parent = hitHumanoid.Parent.HumanoidRootPart --// Parenting it
local velocity = Instance.new("LinearVelocity") --// Creating the LinearVelocity
velocity.Name = "Knockback" --// Naming it
velocity.Attachment0 = attachment
velocity.Parent = hitHumanoid.Parent.HumanoidRootPart --// Parenting it to the HumanoidRootPart
velocity.MaxForce = 1000000 --// Setting the max force (the most amount of force that will move the character)
velocity.VectorVelocity = character.HumanoidRootPart.CFrame.LookVector * 30 --// Setting the vector velocity (the velocity direction it will move in)
velocity.Enabled = true --// Enabling it (not necessary. It is enabled by default. I always like to make sure lol)
game.Debris:AddItem(attachment, 0.7) --// Deletes the attachment after 0.7 seconds
game.Debris:AddItem(velocity, 0.7) --// Deletes the velocity after 0.7 seconds
end