looking on devforum trying to find a good way to create knockback, i found a way to create it by using BodyVelocity.
I added one to my code but for some reason its not doing anything, heres the code
Code
lArm.Touched:Connect(function(hit)
if not hit:IsA("BasePart") then
return
end
local hum = hit.Parent:FindFirstChild("Humanoid")
local humPart = hit.Parent:FindFirstChild("HumanoidRootPart")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://8248431840"
local track = hum:LoadAnimation(animation)
---------------------------
if hum and hit:FindFirstAncestorWhichIsA("Model") then
hitbox.Position = humPart.Position
hitbox.Size = humPart.Size
hitbox.Parent = hit.Parent
hitbox.Anchored = false
hitbox.Transparency = 1
weld.Parent = hitbox
weld.Part0 = humPart
weld.Part1 = hitbox
hitbox.Touched:Connect(function(per)
if db == false then
db = true
hum:TakeDamage(5)
if hum.Health <= hum.MaxHealth then
db = true
track:Play()
hum.WalkSpeed = 0
-------------------------------------
local BV = Instance.new("BodyVelocity")
BV.Parent = humPart
BV.MaxForce = Vector3.new(5000,5000,5000)
BV.Velocity = humPart.Parent:WaitForChild("Head").CFrame.LookVector * -20
wait(.3)
BV:Destroy()
-------------------------------------
task.wait(.3)
hum.WalkSpeed = 16
db = false
end
task.wait(1.5)
hitbox:Destroy()
db = false
end
end)
Im not sure whats wrong, help and feedback would be appreciated