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
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)
w.Parent = RightHand
NewRock.Parent = Char
So then I can help more directly, is this a tool or a normal part, I can help with both.
Get this plugin, should do the trick: Weld - Roblox
It’s normal, I prefer to not use tools
Does this plugin supports in-game coding or ever-changing positions in-game? I don’t think it would handle my problem
So you want to weld a part to a part and change the weld through a script like a CFrame animation?
I want to create the part, weld it, keep weld C0 changing as long as animation keeps on and then break it. All in-game.
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.
Thanks for your answer, but I am not truly sure you understand my question. Still I appreciate it!
So you are running an animation while changing the C0 of the motor6d that is in the animation?
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.
Is the rock being thrown using physics or is it being welded through the air?
Using physics. I delete weld just before throwing process starts.
Did you try welding it to HumanoidRootPart since that is centered?
Thought of it. How can I find the exact C0 for welding to HumanoidRootPart though? Pythagorean Theorem?
Try multiplying the C0 with CFrame.New(x,y,z) maybe?
That doesn’t seem so easy, or I am missing something here. Absolutely easier than hand welding though…
I assume I need red vector. How can I get it? It can easily change according to HumanoidRootPart’s CFrame
I will do some work and deliver the code for you if I can. Probably by tomorrow- i’ve done something similar to this.
Thank you very much it would be really lovely! I’ll try something either.
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.
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
W.C0 = CFrame.new(0, 0, 1)
W.Parent = char.HumanoidRootPart
for i = 0.1, 1, 0.1 do
W.C0 = CFrame.new(0, -i, 1)