How do I weld a sword case to the player's side?

I tried to weld the sword case to the characters side but It didn’t work. How exactly do I script this?

game.Players.PlayerAdded:Connect(function(player)
	
	player.CharacterAdded:Connect(function(Character)
		
		local case = script.Case:Clone()
		case:PivotTo(Character.CFrame)
		case.Parent = Character
		
		
		
		local Weld = Instance.new("WeldConstraint")
		Weld.Part0 = case
		Weld.Part1 = Character.HumanoidRootPart
		Weld.C0 = Weld.Part0.CFrame:ToObjectSpace(Weld.Part1.CFrame)
		Weld.Parent = Character
	end)
end)


Goal ^
Case

2 Likes

Try switching the places of Part0 and Part1.

Weld.Part0 = Character.HumanoidRootPart
Weld.Part1 = case

It may even work better in your favor as well, if you instead change the CFrame of the case to face the direction the Character’s HumanoidRootPart is facing. Something like this

local HumanoidRootPart = Character.HumanoidRootPart
local hrpOrigin = HumanoidRootPart.CFrame

local calculatedCFrame = CFrame.new(hrpOrigin + Vector3.new(-HumanoidRootPart.Size.X, HumanoidRootPart.Size.Y, 0))

-- if it's a model, set the primary part to the case's base.
case:SetPrimaryPartCFrame(calculatedCFrame))
-- else, use this.
case.CFrame = calculatedCFrame

local Weld = Instance.new("WeldConstraint")
-- you don't have to change the C0. matter of fact, I don't think it's even an existing property for WeldConstraint.
Weld.Part0 = Character.HumanoidRootPart
Weld.Part1 = case
Weld.Parent = case

i didn’t work on my character. I cant see the case on my character’s side still…

game.Players.PlayerAdded:Connect(function(player)
	
	player.CharacterAdded:Connect(function(Character)
		
		local case = script.Case:Clone()
		case:PivotTo(Character.CFrame)
		case.Parent = Character
		
		
		
		local Weld = Instance.new("WeldConstraint")
		Weld.Part0 = Character.HumanoidRootPart
		Weld.Part1 = case
		Weld.Parent = case
	end)
end)

Yeet a dummy in Workspace, then delete everything but keep the humanoid rootpart, position it where you like, then use weldconstraints.

(If you want a file i can give me a second)

After local testing, try locating where the sheath is in the explorer. If it’s inside of the player’s character, then it’s a position issue.

Yeah Im a bit new to scripting so a lua example would be good

I’m not sure if its inside the character Heres the output
ereee

local HumanoidRootPart = Character.HumanoidRootPart
local hrpOrigin = HumanoidRootPart.CFrame

local calculatedCFrame = CFrame.new(hrpOrigin + Vector3.new(-HumanoidRootPart.Size.X, HumanoidRootPart.Size.Y, 0))

-- if it's a model, set the primary part to the case's base.
case:SetPrimaryPartCFrame(calculatedCFrame))

local Weld = Instance.new("WeldConstraint")
-- you don't have to change the C0. matter of fact, I don't think it's even an existing property for WeldConstraint.
Weld.Part0 = Character.HumanoidRootPart
Weld.Part1 = case
Weld.Parent = case

And like I said, you should make the base of the sheath the primary part of the model. If you don’t know how to do that, select the model, click on primary part, then find the part that you want to be the primary part.

You can use accessories. Put your case in the accessory and call it Handle, make an attachment inside the Handle and name it based on what attachment you want it to stick to on someone’s character, and then use the move tool (not the attachment’s move tool it’s quite broken)!

Also, to get a dummy to edit on, look up in the toolbox, “Attachment dummy your rig type.”

Edit: welding and motor6Ds are NOT the way to go at all.

1 Like

sword weld example.rbxl (41.2 KB)
Try this. I added a sword and you can replace it with literally anything.

Does it work with models with two parts?

Can i have the model for the sheath so i can weld it and give code?

hmm Im not gett
dont see.PNG
ing an error but I dont see it on my character /:

Yeah sure one sec I got to make it a download

wait how do I give you a rbx file for it again?

Shieth.rbxl (56.1 KB)
sorry it took so long i had to figure out how to download as rbxm

1 Like

Uh did you read what I said up there? It seriously works I use accessors for armor in my game

Ok I’ll try your method right now

1 Like

Sheath weld for devforum.rbxl (55.7 KB)
Fixed it

However, i mean accessories are a more hacky way, but i dont recommend them because sometimes they can be stuck to the center of the hrp (humanoidrootpart)