I was trying to make a knockback tool with BodyVelocity but I didn’t really like how it looked like it was just lerping so I want to try BodyForce. This is what I have rignt now and it’s not working.
local tool = script.Parent
local head = tool.Handle
local remoteEvent = tool.RemoteEvent
local smash
remoteEvent.OnServerEvent:Connect(function(player, character, charged, magnitude)
local rootPart = character:FindFirstChild("HumanoidRootPart")
if charged then
smash = head.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local character = hit.Parent
local hitRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoid then
local knockback = Instance.new("BodyForce")
knockback.Parent = hitRootPart
knockback.Force = (rootPart.CFrame.LookVector * magnitude) + (rootPart.CFrame.UpVector * magnitude)
wait(1)
knockback:Destroy()
end
end)
wait(0.3)
smash:Disconnect()
end
end)