Problem with welding a part to the hrp

This is what I want it to look like:
Screen Shot 2022-11-24 at 9.51.57 AM

How it looks in the game:
Screen Shot 2022-11-24 at 9.52.32 AM

Code (its a script inside the red circle)

local weld = Instance.new("Weld")
weld.Parent = script.Parent.Parent.HumanoidRootPart
weld.Part0 = script.Parent.Parent.HumanoidRootPart
weld.Part1 = script.Parent

local weld2 = Instance.new("Weld")
weld2.Parent = script.Parent
weld2.Part0 = script.Parent
weld2.Part1 = script.Parent.Parent.HumanoidRootPart
1 Like

Maybe there is a way to set the position?

You’d probably have to set the weld’s C0 or C1 property to be the red part’s CFrame relative to the humanoid root part (so like weld.C1 = humanoidRootPart:ToObjectSpace(redPart.CFrame)). You’re also making 2 welds, you should only need 1 here.

2 Likes

why do you have two welds? only one is required.

nevertheless, you have the set the C1 to a position/cframe at the feet of the character (whatever that position is)

1 Like

Use a WeldConstraint instead of Weld

Like this? this doesn’t work

local weld = Instance.new("Weld")

weld.Parent = script.Parent.Parent.HumanoidRootPart

weld.C0 = script.Parent

weld.C1 = script.Parent.Parent.HumanoidRootPart:ToObjectSpace(script.Parent.CFrame)

WeldConstraints don’t work for me very well.

Couldnt you just set a Offset 2 Studs Below the Actual Position?

local weld = Instance.new("Motor6D")
weld.Parent = script.Parent.Parent.HumanoidRootPart
weld.Part0 = script.Parent.Parent.HumanoidRootPart
weld.Part1 = script.Parent
script.Parent.Position = script.Parent.Parent.HumanoidRootPart.Position - Vector3.new(0,2,0)

Use a motor6D since they don’t break when you move the parts.

1 Like

The C0 and C1 properties are CFrames, so like:

local weld = Instance.new('Weld')

local redPartRelativeToRoot = humanoidRootPart:ToObjectSpace(redPart.CFrame)

weld.Part0 = redPart
weld.Part1 = humanoidRootPart

weld.C1 = redPartRelativeToRoot

Use a Motor6D weld Instead of a normal weld

Im Pretty sure a Motor6D will do the exactly the same thing besides the fact it can be used for animation

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.