Hello, I’m trying to make a some sort of hammer with knockback effect. I use BodyVelocity for the knockback and I am not liking how it looks like it’s just lerping so I want to try ApplyImpulse instead.
This is what I have…
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 hitCharacter = hit.Parent
local hitRootPart = hitCharacter:FindFirstChild("HumanoidRootPart")
if humanoid then
local knockback = Instance.new("BodyVelocity")
knockback.Velocity = (rootPart.CFrame.LookVector * magnitude) + (rootPart.CFrame.UpVector * magnitude)
knockback.MaxForce = knockback.MaxForce * magnitude
knockback.Parent = hitRootPart
wait(1)
knockback:Destroy()
end
end)
wait(0.3)
smash:Disconnect()
end
end)