I've tried but keep failing :( I want it so when people jump out of my coaster they get teleported next to the station so they can't go on the track Does anyone have any ideas?
COMMUNITY QUESTION
How could you make a seat that teleports someone to a block when they jump out?
1 answer
The solution to your answer is pretty simple, hope this helped. ^w^
Code below with explanation:
local Players = game:GetService("Players")
local seat = script.Parent --This means the script has to be in the seat.
local currentPlayer = nil
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local humanoid = seat.Occupant
if humanoid then --if a player is sitting, then
local character = humanoid.Parent
local player = Players:GetPlayerFromCharacter(character)
if player then
print(player.Name.." has sat down")
currentPlayer = player --sets the player to currentplayer so that we can detect when they stand up
return
end
end
if currentPlayer then --if a player isn't sitting, then
wait(0.5) --has to have a bit of delay otherwise the character seems to get flinged
currentPlayer.Character:MoveTo(Vector3.new(20.46, 0.5, -26.17)) --after the wait is over, move the character to the given position. Obviously you can change this to whatever position you need.
print(currentPlayer.Name.." has got up")
currentPlayer = nil --sets it to nil so that another player can sit on it
end
end)
If this helped make sure to accept my answer. :3
2 comments
0
U guys are amazing tysm x
0
np uwu
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You can check is the Seat.Occupant is nil or not https://developer.roblox.com/api-reference/property/Seat/Occupant