How can I make a knife system?

So, I took a break from roblox studio and… I forgot how to script.

I’m currently making a game that needs a knife system but I need help with it. Yes, I’ve looked on youtube but I’ve found nothing, just outdated videos. Devforum is literally my only choice to ask for help.

Sorry if this post looks wacky haha,

What do you mean by knife system? A tool that can hit enemies? A knife that you can swing once while pressing F? Please give more details

Just a knife tool, when you m1 it does an animation and it damages a player.

1 Like

It took 3 minutes to search on google.

Also, for the damage part I recommend using a detector part instead of blade.Touched. Basically just weld an invisible, canCollide = false part to the player’s hand or HumanoidRootPart, and check if there are any NPCs inside the area with GetTouchingParts when you click

Thanks for the help, I’ll try it out.

Alright, I tried both scripts but it doesn’t work. I looked in the output and there wasn’t any errors. I tried the print function too but it didn’t print aswell and idk what to do

Could you describe what works and what not, and what did you do exactly? The script, how the tool looks etc

Sorry for the late reply, but literally nothing works. There’s just a tool in my inventory and that’s it. No animations are playing, m1’s don’t work.

The knife is just a handle part and a mesh part which is the actual knife. There’s a weld constraint inside the handle which just welds both of the parts together.

I can’t show the scripts right now, but I copied the scripts in the links and just edited it so the paths to the animations and such are correct.

local player = script.Parent.Parent.Parent
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local equipAnim = humanoid:LoadAnimation() -- load an animation you want to use
local unequipAnim = humanoid:LoadAnimation()
local hitAnim = humanoid:LoadAnimation()

script.Parent.Equipped:Connect(function(a)
	equipAnim:Play()
end)

script.Parent.Unequipped:Connect(function(a)
	unequipAnim:Play()
end)

script.Parent.Activated:Connect(function(a)
	hitAnim:Play()
end)

I just tried this script and it works for me. It is just a normal script in the tool, next to the Handle and that’s it.

That script doesn’t work either. I’m starting to think it’s because of the knife’s properties. Should I turn on massless or should I keep it off?

It doesn’t matter if it’s massless or not (but massless is better), it should work. If that script doesn’t work, something else is the problem. Are there still no errors in the output?

Yeah, there aren’t any errors in the output.

Nevermind, I just noticed today that the animation is in R6 and the game avatar settings is R15. I think I fixed it but thanks for helping :slight_smile: