How can i add knockback to a tool?

Hello, I currently have a baseball bat tool that I want to add knockback to, I have gotten help with this before but the help I did receive wasn’t very helpful for the game I was originally making

people are telling me to use body velocity, I have tried using knockback modules but to no avail. Any suggestions?

Thank you in advance

Well you could make a body velocity that finds the look vector of the bat and then applies it to the velocity of the body velocity which causes the player to fling back in an unstoppable motion until they hit a wall.

i did not understand anything you said.
i don’t even know how to work with body velocity very well to begin with.

Try reading this:

i’m still very new to scripting so i don’t know how i’d apply these in a script

Edit: I have no idea how people keep stumbling on this post BUT DON’T USE THIS. BODY VELOCITY IS NOW DEPRECATED AND SHOULD NOT BE USED ANYMORE.

idk how to explain lol but heres a code you may be able to tweak:

local tool = script.Parent
tool.Activated:Connect(function()
	script.Parent.Handle.Touched:Connect(function(hit)
		if hit and hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("HumanoidRootPart") then
			local KnockBack = Instance.new("BodyVelocity")
			KnockBack.Name = "Knockback"
			KnockBack.MaxForce = Vector3.new(10000,10000,10000)
			KnockBack.Velocity = hit.Parent.HumanoidRootPart.CFrame.LookVector * -100
			KnockBack.Parent = hit.Parent.HumanoidRootPart
			wait(0.25)
			KnockBack.Velocity = Vector3.new(0,0,0)
			KnockBack:Destroy()
		end
	end)

end)
6 Likes

ah, i see
i’ll see what i can learn from this and if it works. thank you very much

it gave me an error in the output at line 11, expected Vector3 but got number
what does that mean?

sry that was a typo ill fix it real quick

ah it worked now. thank you so much