Hello. So I have this van model in my game and I’ve been trying to weld the player to the van in order to move the player with the van. (Van is moving via tween) But what happens instead is the player just starts floating in the air and not even moving with the van.
Any idea of how I could do this?
Sorry if this is the wrong category to ask this in.
I’ve tried this script to weld the player’s Left Foot to the van:
Would I Tween the Player’s CFrame to match the van’s Tween?
I thought of something like that but I wasn’t sure how that would work if there were multiple people in the van.
Sorry if the solution is obvious.
It may not be the smoothest van ever but you’ll want to weld every part in the van to its primary part, then weld the primary part to the left foot. That way everything is attached and follows the primary part. You can create a loop script to weld every part in the van and either put it in the cmd bar or in a script.
Here is the script to save time:
local function WeldModelToPrimary(Part1)
for i, part in pairs(Part1:GetDescendants()) do
if part:IsA("BasePart") and part ~= Part1.PrimaryPart then
local weld = Instance.new("WeldConstraint")
weld.Part0 = part
weld.Part1 = Part1.PrimaryPart
weld.Parent = part
end
end
end
WeldModelToPrimary(workspace.Van) --Keep in mind to make the van body the primary part
Also, this is deprecated:
local Weld = Instance.new("WeldConstraint", hit.Parent.LeftFoot)
Do this instead
local Weld = Instance.new("WeldConstraint")
Weld.Parent = hit.Parent.LeftFoot
That might work. Except that the van is one Union. I could make the Union the primary part to see if that would work. I’ll try that later and get back to you.
Thanks!
I also forgot that you need to set the vans CFrame to the character. Also, whatever body part you attach the weld to is what the van will follow. You set it to the humanoid root part, but the parent to the left foot.
Welds won’t work if the part is anchored because you’re character will be anchored along with it. I’m not sure why it still isn’t working what exactly is happening?
Oh I see, I thought you wanted to make the van follow the player. An easier way to do this is to have multiple seats/parts and just weld the player to those parts. Also, instead of setting the Van’s CFrame you’ll want to set the HumanoidRootPart’s CFrame to the van or seat.
Almost, you’ll want anchored parts welded to the van. Then weld the HumanoidRootPart to those parts and set the CFrame. They have to be anchored so the player cant move.
No problem. You can weld the seats to the van so they stay instead of constantly changing them. By set the cframe I mean set the humanoid root part’s cframe to seat once, then weld.