Problem with welding knife to back

Hey, I’ve been having this problem for about 4 days now, it’s starting to get frustrating. Pretty much, I’m sure you guys have all seen the games that have the items on your back, like knife and gun in Murder Mystery 2, and Hammer and Gem in Flee the Facility.

In my game it’s a knife, and I can’t seem to get it working. The script has changed many times, but currently this is how it looks:

task.spawn(function()
	player.Character:WaitForChild("UpperTorso")
	
	local weld = Instance.new("WeldConstraint")
	weld.Name = "BackKnifeWeld"
	
	local equippedKnife = RS.KnifeResources[player:WaitForChild("Knives"):GetAttribute("Selected")]:FindFirstChildWhichIsA("Tool").Handle:Clone()
	equippedKnife.Name = "BackKnife"
	equippedKnife:PivotTo( 
		player.Character.UpperTorso:WaitForChild("BodyBackAttachment").WorldCFrame * 
			CFrame.fromEulerAnglesYXZ(math.rad(-45), math.rad(-90), 0))
	equippedKnife.Parent = player.Character
	
	weld.Part0 = player.Character.UpperTorso
	weld.Part1 = equippedKnife
	weld.Parent = player.Character
end)

Pretty much this code runs RIGHT after .CharacterAdded() is fired.

It just doesn’t work though :frowning:

Here’s what I know:
– It has nothing to do with cloning problems. Nothing.
– It has nothing to do with CFrame math, because I’ve seen it work before.

Any questions, please ask.

Another thing, when you check what the weld is welded to in the explorer, it always says it’s welded to the knife but not the UpperTorso, even though I weld it.

1 Like

Have you tried to find the problem with print statements? Could you explain what makes it “not work?”

Yes, sir.

There are no errors in the console.

It always works when you spawn, but when you reset it stops.

You need to continuously connect the event each time they spawn. What kind of script is it? Where is the script located?

It’s a server script, of course, I hope this problem doesn’t have to do with any network ownership issue, which it probably shouldn’t. But I’m pretty sure you’re only supposed to connect the event once to the player.

Is this your entire script?

no, the actual script is huge.

So, to get things straight, you want to weld a tool on the player’s back?

1 Like

So what exactly is the problem with this?

The knife, it works the first time you spawn, but then when you die and respawn it doesn’t.

Tell me what this prints, I just want to make sure .CharacterAdded is being fired:

task.spawn(function()
	print("CharacterAdded")
	player.Character:WaitForChild("UpperTorso"):WaitForChild("BodyBackAttachment")
	print("CharacterLoaded")

	local weld = Instance.new("WeldConstraint")
	weld.Name = "BackKnifeWeld"
	weld.Part0 = player.Character.UpperTorso

	local equippedKnife = RS.KnifeResources[player:WaitForChild("Knives"):GetAttribute("Selected")]:FindFirstChildWhichIsA("Tool").Handle:Clone()
	equippedKnife.Name = "BackKnife"
	equippedKnife:PivotTo(player.Character.UpperTorso.BodyBackAttachment.WorldCFrame * CFrame.fromEulerAnglesYXZ(math.rad(-45), math.rad(-90), 0))
	equippedKnife.Parent = player.Character

	weld.Part1 = equippedKnife
	weld.Parent = player.Character.UpperTorso
end)
1 Like

It prints both. But still there is no knife.