This is the script, I am also using the plugin, Tag Editor

local SEATS_TAG = "Passenger Seat"
local SIT_DISTANCE = 10

local cs = game:GetService("CollectionService")
local cas = game:GetService("ContextActionService")

local player = game.Players.LocalPlayer
local humanoid = script.Parent:WaitForChild("Humanoid")

local seats = cs:GetTagged(SEATS_TAG)


local closestSeat = nil


function SitRequest(name, state, input)
	if (state == Enum.UserInputState.Begin) then
		if (closestSeat) then
			if (humanoid.Sit) then
				humanoid.Jump = true
			else
				closestSeat:Sit(humanoid)
			end
		end
	end
end


cs:GetInstanceAddedSignal(SEATS_TAG):Connect(function(seat)
	table.insert(seats, seat)
end)

cs:GetInstanceRemovedSignal(SEATS_TAG):Connect(function(seat)
	seats = cs:GetTagged(SEATS_TAG)
end)


cas:BindAction("SitRequest", SitRequest, false, Enum.KeyCode.E, Enum.KeyCode.ButtonX)


while (true) do
	local seat = nil
	local minDist = math.huge
	for _,s in pairs(seats) do
		local distance = player:DistanceFromCharacter(s.Position)
		if (distance < SIT_DISTANCE and distance < minDist) then
			seat = s
			minDist = distance
		end
	end
	closestSeat = seat
	player.PlayerGui.Gui.SitMessage.Visible = (seat ~= nil and not humanoid.Sit)
	wait(0.1)
end

3 comments

0

Please use Code Blocks when inserting an Script. You can do it easily by Editing the post, selecting the script and clicking on the Lua button

0

I doubt anyone can assist you with your script looking like that. Put it in CODE BLOCKS.

0

This is a non-constructive question. Do not take a free model script and expect for us to fix it. Write your own scripts next time.