I have made some code which makes the player teleport infront of the seat so the player can get out without having to jump since i have disabled it but it wont make the seat sitable again after getting out of the seat. help
Script
local userInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local currentSeat = nil
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Seated:Connect(function(isSeated, seatPart)
if isSeated and seatPart:IsA("Seat") then
currentSeat = seatPart
else
currentSeat = nil
end
end)
end
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end
userInputService.InputBegan:Connect(function(input, isProcessed)
if isProcessed then return end
if input.KeyCode == Enum.KeyCode.E and currentSeat then
local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
if humanoid and currentSeat then
currentSeat.Disabled = true
humanoid.Sit = nil
if currentSeat then
local seatPosition = currentSeat.Position
local seatOrientation = currentSeat.CFrame.LookVector
local offset = seatOrientation * 5
local newPosition = seatPosition + offset
local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
currentSeat.Disabled = nil
if rootPart then
rootPart.CFrame = CFrame.new(newPosition.X, seatPosition.Y, newPosition.Z)
rootPart.CFrame = CFrame.new(rootPart.Position, seatPosition)
end
end
end
end
end)