I made a car that you can enter and exit but when you exit the car, it’s supposed to teleport your character to the grey part but it teleports your character on the other side of the car.
local vehicle = script.Parent.Parent
local Body = vehicle:WaitForChild("Body")
local VehicleSeat = script.Parent
local EnterPrompt = VehicleSeat:WaitForChild("EnterPrompt")
local DriveSeatExit = Body:WaitForChild("DriveSeatExit")
local currentDriver = nil
local function EnterVehicle(player)
local character = player.Character
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
VehicleSeat:Sit(humanoid)
currentDriver = player
end
end
local function ExitVehicle()
if currentDriver ~= nil then
local character = currentDriver.Character
if character then
local characterHeight = character:GetPivot().Y
local pos = DriveSeatExit.CFrame + Vector3.new(0, (characterHeight + DriveSeatExit.Size.Y), 0)
character:PivotTo(pos)
end
currentDriver = nil
end
end
EnterPrompt.Triggered:Connect(function(player)
EnterVehicle(player)
end)
VehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
ExitVehicle()
end)