Hello there roblox dev community! I have a question I hope you guys can answer. My question is how would you teleport to a different game/experience when you sit in a seat? I cant seem to find anything to be able to teleport when sitting. If any of you can help with this, would be much appreciated. Thank you!
Hello there,
That’s a weird problem you are having as teleporting to different places whilst being seated works fine for me. Are you receiving errors or warnings in the console?
Anyhow, if neither is the case, have you tried forcing the player to jump. This un-seats the player. Furthermore, you could disable the seat on the player’s end so they won’t be able to sit down again.
I hope that this helped you out.
If you have questions please let me know.
- DosenSuppe2_0
You can bind an event to the humanoids “Seated” event or a seats “Occupant” property to achieve this. Here are a few examples how you can do it using both those properties.
TeleportAsync() only works on the server.
Please do keep in mind teleports can fail so always make sure to add your own fail logic into your code.
Using the seated event of a humanoid:
local Service = game:GetService("TeleportService")
local Plr = [PlayerToTeleport]
local PlayersToTeleport = {Plr}
local Hum = Plr.Character.Humanoid
local PlaceId = 0
Hum.Seated:Connect(function()
Service:TeleportAsync(PlaceId,PlayersToTeleport)
end)
Using the occupant property of a seat:
local Service = game:GetService("TeleportService")
local Seat = [YourSeat]
local PlaceId = 0
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local Plr = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
Service:TeleportAsync(PlaceId,{Plr})
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.