I’m trying to weld a part to a player, but I want it to weld onto a very specific point(via a script). However, this just causes for the part to go to the center of the player’s character(eg Left Arm, Right Arm). Is there any way to weld it to a specific place?
local weld = Instance.new("Weld")
bullet.Position = m -- the position of the mouse
weld.Part0 = bullet
weld.Part1 = hit
weld.Parent = hit
You can achieve this by using the “Weld.C1” cframe property which is subtracted from the “original cframe” which is the cframe of “Weld.Part0” in this case. To do this, you can use the :ToObjectSpace() method of the part you want it to be welded to then inverse it since it is subtracted rather than being an offset. Example:
local Weld = Instance.new("Weld")
Weld.Parent = bullet
Weld.Part0 = hit
Weld.Part1 = bullet
local WeldingCfr = CFrame.new(m) --This is the world cframe where you want the bullet to be welded to
local ObjectCframe = hit.CFrame:ToObjectSpace(WeldingCfr):Inverse()
Weld.C1 = ObjectCframe
Hey! Do you know a way for this to not only weld the dart to a specific part of a player, but also have it face away from the direction in which it came from. I changed my bullet into a dart, and noticed that it faces the completely wrong.
As you can see, I shot from behind it, but the tip of the dart isn’t facing where it should be.
Im not sure how you calculated where the bullet should be positioned but if you have the position where the bullet came from, you can replace the previous code with something similar to this:
local Weld = Instance.new("Weld")
Weld.Parent = bullet
Weld.Part0 = hit
Weld.Part1 = bullet
local OriginPos = --change to the position where the bullet originated from
local newLookVector = (m-OriginPos).Unit
local WeldingCfr = CFrame.lookAt(m, m + newLookVector) --This is the world cframe where you want the bullet to be welded to
local ObjectCframe = hit.CFrame:ToObjectSpace(WeldingCfr):Inverse()
Weld.C1 = ObjectCframe