The title of the topic explains it all, but here is an example of what I am talking about:
I have small parts on each side of the car (where the player teleports out of the car). However, sometimes if there is a part on the side of the car, the player gets stuck.
What is the best way to fix this problem?
Code:
local function SitPlayerInSeat(Seats)
Seats.Part.ProximityPrompt.Triggered:Connect(function(Player)
if Seats.Occupant then return end
if Player then
-- local NameTag = Player.Character.Head:WaitForChild("NameTag")
local Humanoid = Player.Character:FindFirstChild("Humanoid")
if Humanoid then
Seats:Sit(Humanoid)
Seats.Part.ProximityPrompt.Enabled = false
-- NameTag.Enabled = false
RemoveAccessorys(Player)
local SeatConnection
SeatConnection = Seats:GetPropertyChangedSignal("Occupant"):Connect(function()
Seats.Part.ProximityPrompt.Enabled = true
-- NameTag.Enabled = true
wait(0.1)
if Seats.Name == "FR" or Seats.Name == "BR" or Seats.Name == "Middle" then
Player.Character.HumanoidRootPart.CFrame = Seats.Parent.RightSide.CFrame
elseif Seats.Name == "BL" then
Player.Character.HumanoidRootPart.CFrame = Seats.Parent.LeftSide.CFrame
elseif Seats.Name == "DriveSeat" then
Player.Character.HumanoidRootPart.CFrame = Seats.Parent.Body.LeftSide.CFrame
end
AddAccessorys(Player)
SeatConnection:Disconnect()
end)
end
end
end)
end
local function GetAllSeats()
for _, Seats in pairs(CollectionService:GetTagged(Seats_Tag)) do
SitPlayerInSeat(Seats)
end
end
GetAllSeats()