Uhh, some help needed on my Hanging knife thingy script

Heyy, need some help here, so I’ve been trying to make a script that hang or erm welds a display knife to the player’s torso like Murder Mystery, here’s my code and it works well with normal torso but breaks with other type of torso.

function module:Knife(player)
	local char = player.Character 
	local hand = game:GetService("ServerStorage"):WaitForChild("KnifeLeft"):clone()
	hand.Parent = char
	hand.CFrame = char:WaitForChild("LowerTorso").CFrame*CFrame.new(Vector3.new(1,-0.55,0.2))*CFrame.Angles(math.rad(15),math.rad(-180),math.rad(-180))
	weldBetween(char:WaitForChild("LowerTorso"), hand)
	hand.CanCollide = true
	hand.Anchored = false
	
	
end

function weldBetween(a, b)
	local weld = Instance.new("ManualWeld")
	weld.Part0 = a
	weld.Part1 = b
	weld.C0 = CFrame.new()
	weld.C1 = b.CFrame:inverse() * a.CFrame
	weld.Parent = a
    return weld
end

What exactly do you mean when you say it “breaks with other type of torso”?

ummm torso other than the default torso idk how to describe it

What exactly is the problem though? Is there an error, or does it just not look right? Just need a bit more information.

1 Like

This is what it’s supposed to do
arghhhhhhhhhhh1
But this happens whenever other type of torso is equipped, sometimes the knife falls off (the knife in this picture(2nd pic) is a skin and it has probably has nothing to do with it because the same thing happens with every other skins)
argggggggggggghhhhhhhhhhh

It’s really hard to see anything in those pictures haha. Do you get an error in your console at all? I suspect you would be.

Alright, i will take a new pictures and no, absolutely no errors

The problem is not in the different, packaged torsos, but in the different skins.
Different torso are just meshed regular ones, so they are not affected.

sadaaddadad


for some reason the knife replaces my leg too lol

Well, we’re trying but nothing you sent makes sense as to why it does that.
Can you send the entire script?

What are you changing with the torso, exactly?

Uhhh nothing but changing the torso to another type of torso in the avatar menu which everyone is able to do

Hmm, okay. Can you take a screenshot of your character model tree in the workspace window? That might give us a bit more information

For some reason, the weld isn’t anywhere in there (Lower Torso, KnifeLeft)


argggggggggghh

Ah there it is. In your KnifeLeft you have LeftHipRigAttachment. That’s what I was thinking it might be. Remove those attachments and welds from the knife. When a character is created it looks for those attachments in order to weld things.

eyyy one problem solved and now for some reason the weld gets removed and the knife falls right off
uhhhhhh

I made a mini tutorial on doing things like this. You can use my tutorial as a point of reference for your system, just change some names and positions around. You should, in fact, do it this way over hard-coded CFrame math so you can account for different avatar bundles which bring different hip positions.

Alright thanks, I will try this tomorrow as i’m going to sleep rn and finally I can sleep properly (hopefully xd) without my mind constantly thinking about a solution to a still unfixed bug that I’ve found and thinking about what else to do tomorrow, it’s hard being a developer and i’m tired, hopefully my game will come out to a success when it’s publicly released.

Uhh so how do I move the knife?

manually. By multiplying either C0 or C1 of the weld with CFrame Values.
Remember CFrame is tilted along with the object’s facing direction. CFrame.new(0,0,-1) to make it move forward, etc.

or make a tool yourself, by making two objects in a separate positions, then using a script to subtract the Knife part CFrame by the Part CFrame.
local C0 = Knife.CFrame * Part.CFrame:inverse()