Pivot keeps pivoting on the opposite direction

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.

image

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)

Why aren’t you just pivoting to the DriveSeat’s CFrame?

Uhhh… why?

I also found out that waiting for a couple of seconds and then teleporting would work but is there any thing better than this?

Maybe instead of doing PivitTo you could replace it with:

character.HumanoidRootPart.CFrame = -- your code

But they’re almost the same thing so no point really.

PivotTo() would make this a whole lot easier, It allows you to Move the Whole Model using CFrames

This worked.

repeat task.wait()
	humanoid.Sit = false
until humanoid.Sit == false

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.