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

How can I force a player to sit in a seat?

I am working on a game in which players will build vehicles and then fight other players in them, and have run into a problem with how I force players into their vehicle's seat when the game starts. All I do to make the character sit is to set their position to the seat's position using :MoveTo() and to set their Jump power to 0 so that they can not exit the seat. The only problem is that when there is a block directly above the seat the character usually spawns in on top of the block instead of in the seat. I am looking for a way to force the character directly into the seat, without any chance of missing. Is there a way for me to force the seat weld to be created without the character having to walk onto or be teleported onto the seat so that the character has a 100% chance of siting in the seat? Just in case, here is the part of my vehicle build code that deals with the teleportation:

	game.Players.LocalPlayer.Character:MoveTo(Seat.Position)
	game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0

Thanks in advance for your help.

1 comment

0

I have an Idea of setting the CFrame of the humanoid root part to the seats CFrame and then creating a weldConstraint to hold it there, but Im not sure how well that would work and it seems a bit hacky what to you guys think?

2 answers

✓ Accepted answer

Use Seat:Sit(humanoid) to force a humanoid to seat on a Seat object.

https://developer.roblox.com/en-us/api-reference/function/Seat/Sit

If you're not using a Seat object and instead your own custom seat, your comment would work:

I have an Idea of setting the CFrame of the humanoid root part to the seats CFrame and then creating a weldConstraint to hold it there, but Im not sure how well that would work and it seems a bit hacky what to you guys think?

1 comment

0

thanks! this is exactly the kind of thing I was lookign for :)

Like Twinbrotato said, you just simply use the Sit property of the humanoid.

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