Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make a Humanoid move with a Model?

I have a "Move" module. One of the functions moves a train model at its specific orientation.

function move.moveTrain(car)
	car:SetPrimaryPartCFrame(car.Base.CFrame + car.Base.CFrame.LookVector * 1)
	car:TranslateBy(Vector3.new(0, 0, 0.1))
	wait()	
end

The problem is, when I call this, if the player is not in a seat in this model, the train moves without the humanoid(s). How do I anchor, so-to-speak, a humanoid to a model so that he or she will move with the model, and can walk around, sit, and stand him- or herself?

I have looked at Humanoid:MoveTo, but I am confused as to how to apply it to my situation.

7 comments

0

Do you mean to move the model?

0

Oh, you said to move the model with the character.

0

Yes, I would like to move the character with the model, more precisely.

0

You could weld each players HRP to the base of the car.

0

Is that a common practice? I'm reading about the Weld class right now on the Docs.

0

The simplest way I can think of doing it is using a rope constraint and attaching it to the character with the humanoid and the part so that whenever the part moves, the character with the humanoid does too.

0

@Pokemaster can you explain this further with code in an answer, please?

1 answer

I'm unsure of exactly what you mean, but I can think of two things that you might want to accomplish:

  1. You want the player to move with the train (this wouldn't allow them to move).

  2. You want them to move with the train while still being able to move.

The first one is going to be easier to do. All you would need is to weld Character.HumanoidRootPart to some non-animated part of the train.

Edit: you could even use a WeldConstraint so you wouldn't need to calculate the C0.

For the second one. Someone made a gravity controller thing that could actually help with this situation (it's linked here). You could particularly use the Wall stick one. It should be fine as long as you give credit. When I played around with it, I was able to disable the actual gravity feature and disable it for some parts. For disabling it for some parts, theres a check somewhere in the local script that checks if the name of the part is something like "ignore"; this isn't ideal, so you could change the check to something like seeing if there's a bool value in it is named "Gravity" or something, but for disabling the actual gravity changing, I don't remember what I changed.

2 comments

0

Would the second method let the player sit, stand, walk around all while in the moving model?

0

You would need to disable it before you sit, but it allows you to walk around and stuff.

This discussion is preserved as it was. New answers, comments, and votes are closed.