How to make a script that teleports a player that touched something into a seat?

I’m working on a story game, and I don’t know how to do that one script.

Basically if a player touches a wall or something, they get teleported into a certain seat in a certain bus.

2 Likes

You can just use Instance:MoveTo(Vector3 position) here. All you have to do is:

player.Character:MoveTo(seat.Position); -- NOT Humanoid
1 Like

There’s a method called Sit() that makes the humanoid in the parameter sit in that seat, so all you need to do is put that in a touched event.

Wall = ---Path to your wall
Seat = ---Path to your seat

Wall.Touched:Connect(function(Hit)
      if Hit.Parent:FindFirstChild("Humanoid") then
            Seat:Sit(Hit.Parent.Humanoid)
      end
end)

EDIT:

Didnt mean to reply that to you @snorebear sorry

1 Like

Sure, that works too! However, if at any time, the story decides to change. The MoveTo will be more useful than a Sit function.

To add onto what @C0lvy123 said, you can set the walkspeed and jumppower to 0 to disable moving and as a added precaution (tho really its on the client and plus its just a teleporting bus) :man_shrugging:, then you can go straight to requiring the module and disabling movement all together.

@snorebear I’m pretty sure this is like for the lobby part of teleportation, plus, using MoveTo() wouldn’t neccessarily mean it would pathfind it’s way perfectly into the seat, it can get stuck in a wall.

Though If you really wanted to get complicated, you can set specific walk points on the bus that the player is forced to follow via tween/other methods of movement and add a walking animation :man_shrugging:

You’re thinking of the Humanoid MoveTo. I am talking about Model:MoveTo. However, SetPrimaryPartCFrame may be more effective here.

1 Like