I have 2 parts, Cube1 and Cube2. They are located inside a folder and I want to make a weld so that when one moves, the other will too.
The code that creates the weld is this:
local weld = Instance.new("Weld")
weld.Name = "CubeWeld"
weld.Part0 = cubeTable[1]
weld.C0 = cubeTable[1].CFrame:Inverse()
weld.Part1 = cubeTable[2]
weld.C1 = cubeTable[2].CFrame:Inverse()
weld.Parent = cubeFolder:FindFirstChild("CubePart1")
This doesn’t work, of course. So I am asking for help: Anyone knows how to fix this?
(I am moving one cube with a tween and I want the other cube to “stick” to the other one and move with it.)
2 Likes
Another note is that the script DOES run, I see that the weld is created and it is attached to the parts as expected.
1 Like
flarezhu
(Flarez)
September 11, 2020, 2:02pm
#3
Maybe put the parts in a hierarchy with the cube that you are tweening as the parent? Not sure
1 Like
What is a hierarchy? (ahhhhhhhhhhh)
2 Likes
flarezhu
(Flarez)
September 11, 2020, 2:24pm
#5
Basically when you put a part into another part. It’s really easy to do- just drag Cube 2 into Cube 1 and and weld the 2 parts together. (You can use a plugin to do so, instead of a script.)
flarezhu
(Flarez)
September 11, 2020, 2:27pm
#6
Ask me if you have any other questions on part hierarcies.
1 Like
And what would the weld’s parent be?
flarezhu
(Flarez)
September 11, 2020, 2:35pm
#8
That I’m not sure of: maybe Cube01??? You can try and experiment with both to see which one works.
1 Like
Alright I will experiment with that.
1 Like
xZylter
(xZylter)
September 11, 2020, 2:42pm
#10
Switch out Instance.new("Weld")
with Instance.new("WeldConstraint")
.
1 Like
Why does that matter?
I’d like to know so I will understand for next time I do these things.
xZylter
(xZylter)
September 11, 2020, 2:43pm
#12
It’s the more modern form of a weld that in my testing actually works. In the past I have made this mistake and using a WeldConstraint fixes it.
1 Like
It doesn’t work.
Part0 is the CubePart1,
Part1 is the CubePart2,
and the weld is parented to CubePart1.
xZylter
(xZylter)
September 11, 2020, 2:45pm
#14
Did you remove C0
and C1
from your code when using the WeldConstraint?
1 Like
Yes I did, it gave me an error when I didn’t.
xZylter
(xZylter)
September 11, 2020, 2:50pm
#16
Are you tweening the CFrame or Position? I found a post on the DevForum that mentioned that Position causes issues with welds.
Hello, I’m trying to create a sliding door for a shop I am making. I have made sliding doors that used TweenService before, but now it doesn’t seem to be working as expected. I used weld constraints to connect parts of the door to a “Main brick” which would be tweened but wouldn’t be visible in the game. The “Main brick” does tween as intended, but the parts welded to it won’t budge.
The decorative door parts welded to the “Main brick” are unanchored, and the “Main brick” itself is anchored. Th…
1 Like
I am tweening position and orientation separately.
I need to specify the degrees for my code, I can’t use look vectors. That’s why I am using position and orientation separately.
How do I fix this then?
1 Like