Once you sit in the seat, a GUI button will pop up that once clicked, will teleport you out of the seat.
I am quite new to scripting so the code is pretty rough I know. The main issue i'm having, is that it teleports all of the players that have previously sat in the seat as well instead of just you.
It also uses a remote event to allow the gui to come onto the players screen via localscript.
The following is the code inside of a regular script in a normal Part that I am using for the seat. I'm not using an actual seat on purpose.
local seat = script.Parent
sitting = false
sat = game.ServerStorage.Sat.Value -- this is to make sure no one else currently is in the seat
seat.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local mouse = player:GetMouse()
if sat == false then
sat = true
if sitting == false then
humanoid.Sit = true
sitting = true
humanoid.Parent.Torso.Anchored = true
wait(0.01)
humanoid.Parent.Torso.CFrame = CFrame.new(-270.5, 4.5, -14)
humanoid.Parent.Torso.Orientation = Vector3.new(0,180,0)
game.ReplicatedStorage.RemoteEvent:FireClient(player) -- gui pops up
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() -- button to get off the seat is pressed
humanoid.Parent.Torso.Anchored = false
humanoid.Sit = false
wait()
humanoid.Parent.Torso.CFrame = CFrame.new(-270.344, 3.997, -8.701)
wait(0.5)
sitting = false
sat = false
end)
end
end
end
end)
Sorry for the long question. Thanks for any help provided.

1 comment
This is a part right, not an actual seat?