Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Forcing player to sit in a seat?

Asked by 9 years ago

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?

2 answers

Log in to vote
1
Answered by 9 years ago

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.

0
I do not know how to edit the DesiredAngle to make the legs bend 90 degrees, any code? RepeatLua 90 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

Okay, I figured it out myself.

For any other users that want to know, here's the code:

script.Parent.Touched:connect(function(Hit)
    local Char = Hit.Parent
    if Char:FindFirstChild("Humanoid") then
        local W = Instance.new("Weld", script.Parent)
        W.Part0 = W.Parent
        W.Part1 = Char.HumanoidRootPart
        W.C0 = CFrame.new(0, 0.5, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0)
        W.C1 = CFrame.new(0, -1.5, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0)
        Char.Humanoid.Sit = true
    end
end)

Answer this question