How do I weld a part to a tweened object?

So I have an AI car. I am trying to make a queueing system for it so that they can queue up at a red traffic light, for instance. The way I am trying to do it is with a sensor. That is not the problem however.
My problem is that I can’t weld the sensor part to the car. No matter what I try, using a weld constraint, a weld script, or even a plugin, it still doesn’t want to move with the car. And if I try to move it by tweening it with the car, it just centers itself inside the car (not where I want it to be). Does anyone know how to accomplish this?

1 Like

You can either use WeldConstraints or Motor6D’s to attach parts to the part you are tweening. Make sure that all parts you have connected to the part you are tweening are unanchored or they wont tween correctly.

2 Likes

I’ve already tried WeldConstraints. Both parts are anchored, for performance. I do not want to unanchor them.

Welds not work with anchored stuff part or models whatever you cant use welds

You have to unanchor the part that is connected or it simply will not tween. How would anchoring the part give any performance increase?

The less physically moving parts there are in a game, the better the performance. I use TweenService to move the car. Unanchoring it would mean that players could move it off it’s path.

Did you try to add the part inside the car model and tween them together?

Yes. It did follow, but in a wrong spot. It centered itself inside the car, not in front of it.

You are correct in saying that

but unless you have parts in the thousands this will barely affect the performance. Also, If the root part that all the parts are connected to is anchored, the parts that are connected to the root part will act as if they are anchored but are moving along side the root part. Just give it a test and you will see.

The project where I am intending to use these cars has more than 10K parts. And it still doesn’t want to move with the car even the way you described. It just stays in the spot where I added it.

You may want to find a way to reduce the amount of moving parts there are in your game, that might put some pressure on the server. I suggest modelling in Blender since that will only use a few parts per model. Every single part on the model has to be unanchored except for the root part that everything is connected to. Tween the root part to the goal position and it should work fine. Here’s a video of me using this method:


Here’s a picture of my setup in the model, I like to use Motor6Ds:
image

I’m using Rig Edit Lite to connect everything together.

Ok here is the idea
add CFrameValue in the car And tween that value with TweenService
but you need to add script like this

game.Workspace.Car.Value.Value = game.Workspace.Car.PrimaryPart.CFrame

game.Workspace.Car.Value.Changed:Connect(function()
game.Workspace.Car:SetPrimaryPartCFrame(game.Workspace.Car.Value.Value)
end)

Edit: Lol the car dosnt have CFrame

It’s too late to change anything. We started in 2019, and now it’s 2021. And part count is not my problem.

Make sure the part that is being welded (secondary part) isnt anchored.

If its anchored, its not gonna move with the tweened object (tweened object is anchored).

Well, if you don’t want to tween anything on the server there’s always :FireAllClients() you can do all the tweening on the client instead of on the server, that will put less strain on the server

I unanchored it as @Master_Aaron suggested, but it still didn’t move.

can you show the issue in a video so I can see whats occurring? Is the object simply just stuck in place or?

Yeah, it’s stuck in place where I added it. I don’t think you need a video to understand what happens, but here you go anyways.

When running the game, have you checked if the object is anchored? (Both Server and on Client?) or if the weld is deleted/anything is added?

And just to be sure, can you show the part of the script where you tween? And are you 100% sure you are actually playing the tween? I know I forget to :Play() tweens a lot.