Part not in correct position when welded

I’m currently creating a tool that, when equipped, makes a part appear, and said part is named “aura” and is welded to the player’s HumanoidRootPart. I’m trying to make it so the aura is at the HumanoidRootPart’s position.

The problem is, the aura part isn’t at the HumanoidRootPart’s position when it’s welded, it’s always behind it, or above it. The position it’s welded in seems to be random.

Here is the code that creates the aura part and the weld for it.

--Make aura
local aura = Instance.new("Part")
aura.Name = "Aura"
aura.Shape = Enum.PartType.Ball
aura.CanCollide = false
aura.Material = Enum.Material.ForceField
aura.Color = Color3.fromRGB(255, 213, 0)
aura.Massless = true
aura.Size = Vector3.new(shieldTime, shieldTime, shieldTime)
aura.Parent = tool
local auraWeld = Instance.new("WeldConstraint")
auraWeld.Part1 = aura
auraWeld.Enabled = false

--Welding the aura
aura.Position = rootPart.Position
auraWeld.Part0 = rootPart
auraWeld.Enabled = true
auraWeld.Parent = aura
  1. What do you want to achieve? I want to make a tool that welds a part to the player’s HumanoidRootPart

  2. What is the issue? The part is not at the HumanoidRootPart’s position when welded.

  3. What solutions have you tried so far? I searched for similar posts but found no solution.

Both the aura part and the weld is created locally, and the HumanoidRootPart’s position is always at the center of the player’s character.

save the cframe as a variable and apply the cframe to the part after welding, that might work

afbeelding
I am not sure, but maybe adding that position change at the end of the script, then that will update last

Position uses Vector3 which factors in collision. You should use CFrame instead because they do not.
Change

aura.Position = rootPart.Position

to

aura.CFrame = CFrame.new(rootPart.Position)

Aura is a part, not a model just so you know.

What I ended up doing is following what CodeProto said, but also made it so the aura’s position is set to the root part when the tool is equipped, so it’s updated whenever the player sees it.

Apologies, I meant to write:
aura.CFrame = CFrame.new(rootPart.Position)

I’m not too sure how CodeProto’s answer has fixed it, but if it works that’s all that matters! :'D