I'm making a racing game, and I want to force players to sit in a seat. The problem is not to make them stay in the seat, but making them automatically sit. As teleporting the player would be buggy, that's not a solution. What else would work?
A player sitting down is in fact just the game creating a weld between the player's Torso and the seat, as well as bending the limbs 90 degrees forward.
So there are 2 things you need to do: -Weld the torso relative to the seat so that the player appears to be seated. -Edit the DesiredAngle of the Motor6Ds for the limbs that are found under Torso so that the limbs bend 90 degrees forward.
There you go.
Okay, I figured it out myself.
For any other users that want to know, here's the code:
01 | script.Parent.Touched:connect( function (Hit) |
02 | local Char = Hit.Parent |
03 | if Char:FindFirstChild( "Humanoid" ) then |
04 | local W = Instance.new( "Weld" , script.Parent) |
05 | W.Part 0 = W.Parent |
06 | W.Part 1 = Char.HumanoidRootPart |
07 | W.C 0 = CFrame.new( 0 , 0.5 , 0 , 1 , 0 , - 0 , 0 , 0 , 1 , 0 , - 1 , - 0 ) |
08 | W.C 1 = CFrame.new( 0 , - 1.5 , 0 , 1 , 0 , - 0 , 0 , 0 , 1 , 0 , - 1 , - 0 ) |
09 | Char.Humanoid.Sit = true |
10 | end |
11 | end ) |