How to use welds

I’m trying to figure out why the part won’t just weld straight to the character’s body part I choose
When I do weld it the part to the character’s body part it’s like 60 studs away from the character’s
I tried to look at youtube tutorial’s but so far no help, and looking at free models but they are no help either, they sorta have the same problem i’m having as well.

https://gyazo.com/d7e20f5228470c55f91cbfd549392ed0

I tried moving the part position to the character head and it still didn’t work

debounce = true

script.Parent.Touched:Connect(function(touch)
	if touch.Parent:FindFirstChild("Head")  and debounce == true then
		debounce = false
		
		local head = touch.Parent:FindFirstChild("Head")
		
		
		local weld = Instance.new("Weld", head)
		weld.Part0 = head
		weld.C0 = head.CFrame:Inverse()
		
		
		script.Parent.Anchored = false
		
		script.Parent.CanCollide = false
		
		weld.Part1 = script.Parent
		weld.C1 = script.Parent.CFrame:Inverse()
		
		
		wait(5)
		debounce = true
		
	end
end)
1 Like

Is the part anchored? That could be the reason.

No the part is not anchored, in the script I disabled it

1 Like

You don’t need to inverse the head, you can just set the Part0, Part1 and it snaps to it the second you set a parent for the weld.

EDIT: Also I notice your haven’t set a parent for the weld anyways, set the weld.Parent to Head.

I noticed that your code is not getting the each of the part’s relative cframes to eachother.

I’d suggest not setting C1 and instead just set C0 to part.CFrame:toObjectSpace(head.CFrame)

From my experience with welding projectiles on Roblox in the far past, the problem is that the physics engine works in discrete steps. This means that a projectile will go through an object or bounce off an object and be in a new location, and not the position it would be during the exact time of collision. So when you get the touched event signal, it is not on the surface but soemwhere else. So when you attempt to weld a projectile to it’s target on touch, it won’t be on the surface like you expect, but where the projectile will be after some more time. This can also be exaggerated even more with Roblox’s networked physics.

One way to get around this is to possibly raycast from the projectile to the target object and use the ray’s hit position as an estimated collision point to weld the projectile.