Basically, I want to weld a part between two parts, right into the middle. That two parts are character hands and the part I want to weld is a rock. All parts have ever-changing size, rotation and hands have ever-changing distance between. I have no problem with loops while weld is active.
What I’ve tried so far is this:
local w = Instance.new("Weld")
w.Name = "RockWeld"
w.Part0 = RightHand --Right hand of our character
w.Part1 = NewRock --Rock I want to weld
spawn(function()
while w.Parent do
--Mathematical solution I've tried
local MidPoint = (RightHand.Position + LeftHand.Position)/2
MidPoint = MidPoint + Vector3.new(0, -Str*RockHeightModifier, 0)
local C0 = MidPoint - RightHand.Position
w.C0 = CFrame.new(C0)
wait()
end
end)
w.Parent = RightHand
NewRock.Parent = Char
There are two ways, one: use a weld constraint and choose the parts, or two: use a union so then they are always together but you cant edit individual parts.
No, it’s a weld I’m trying to change. It’s not included in animation but welded to a part that is playing with animation.
Here, this should describe.
As you can see in this gif, I can’t get rock between my hands. That’s the exact problem. I feel like I need a mathematical solution that’s all, but please feel free to suggest anything that would solve this.
Okay so I think i’ve done basically in principle what you want. It was pretty simple and the code is easy and clean. As you can see, I also modified it so the ball goes up a little bit so when you animate it it can look even more realistic and like part of in-game physics. This is the code- let me know if you need anything else. Just add this in a script in a sphere like similarly in the gif.
wait(4)
local charName = “crossbar”
local sphere = script.Parent
local char = workspace:WaitForChild(charName, true)
local W = Instance.new(“Weld”)
W.Part0 = sphere
W.Part1 = char.HumanoidRootPart