car=script.Parent.Parent Base=car:FindFirstChild("\066\097\115\101")Left=car:FindFirstChild("\076\101\102\116")Right=car:FindFirstChild("\082\105\103\104\116")function MakeDoor(B,c,o,m)local g=Instance.new("\077\111\116\111\114",car)g.Name=B.Name.."\077\111\116\111\114"g.Part0=c g.Part1=B g.C0=m g.C1=o g.MaxVelocity=.05 c.CanCollide=true local u=false c.Touched:connect(function(B)if not u and(B.Parent and(B.Name=="\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"and(game:GetService("\080\108\097\121\101\114\115")):GetPlayerFromCharacter(B.Parent)))then u=true c.CanCollide=false g.DesiredAngle=math.pi/3 wait(1.5)g.DesiredAngle=0 wait(.5)c.CanCollide=true u=false end end)end function MakeWeldDoor(B,c)local o=Instance.new("\077\111\116\111\114\054\068",car)o.Name=B.Name.."\077\111\116\111\114"o.Part0=c o.Part1=B o.C1=B.CFrame:inverse()*c.CFrame c.CanCollide=false end function GetCFrame(B)if B:IsA("\067\070\114\097\109\101\086\097\108\117\101")then return B.Value elseif B:IsA("\083\116\114\105\110\103\086\097\108\117\101")then local c=nil pcall(function()c=CFrame.new(B.Value:match("\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041\044\040\046\043\041"))end)return c end end for B,c in pairs(car:GetChildren())do if c:IsA("\077\111\116\111\114\054\068")then c:Destroy()end end for B,c in pairs(car:GetChildren())do if c:IsA("\066\097\115\101\080\097\114\116")and c.Name:find("\068\111\111\114\072\105\110\103\101")then local B=c.Name:match("\068\111\111\114\072\105\110\103\101\040\046\042\041")local o=car:FindFirstChild("\068\111\111\114"..B)if o then local B=o:FindFirstChild("\068\111\111\114\067\070\114\097\109\101")local m=o:FindFirstChild("\072\105\110\103\101\067\070\114\097\109\101")if B and m then local g=GetCFrame(B)local u=GetCFrame(m)if g and u then MakeDoor(c,o,u,g)else MakeWeldDoor(c,o)end else MakeWeldDoor(c,o)end end end end if Base then if Left then leftMotor=Instance.new("\077\111\116\111\114\054\068",car)leftMotor.Name="\076\101\102\116\077\111\116\111\114"leftMotor.Part0=Left leftMotor.Part1=Base leftMotor.C0=CFrame.new(-WheelSize/2-Left.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,-math.pi/2)leftMotor.C1=CFrame.new((Base.Size.x/2+Left.Size.x)+WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)leftMotor.MaxVelocity=motorSpeed end if Right then rightMotor=Instance.new("\077\111\116\111\114\054\068",car)rightMotor.Name="\082\105\103\104\116\077\111\116\111\114"rightMotor.Part0=Right rightMotor.Part1=Base rightMotor.C0=CFrame.new(-WheelSize/2-Right.Size.x/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)rightMotor.C1=CFrame.new((-Base.Size.x/2-Right.Size.x)-WheelSize/2,0,0)*CFrame.Angles(math.pi/2,0,math.pi/2)rightMotor.MaxVelocity=motorSpeed end end
--don't touch below, very delicate
car = script.Parent.Parent

Base = car:FindFirstChild("Base")
Left = car:FindFirstChild("Left")
Right = car:FindFirstChild("Right")

function MakeDoor(hinge, door, hingeOffset, doorOffset)
	local doorMotor = Instance.new("Motor", car)
	doorMotor.Name = hinge.Name .. "Motor"
	doorMotor.Part0 = door
	doorMotor.Part1 = hinge
	doorMotor.C0 = doorOffset
	doorMotor.C1 = hingeOffset
	doorMotor.MaxVelocity = 0.05
	door.CanCollide = true
	local doorDebounce = false
	door.Touched:connect(function(it)
		if
			not doorDebounce
			and it.Parent
			and it.Name == "HumanoidRootPart"
			and game:GetService("Players"):GetPlayerFromCharacter(it.Parent)
		then
			doorDebounce = true
			door.CanCollide = false
			doorMotor.DesiredAngle = math.pi / 3
			wait(1.5)
			doorMotor.DesiredAngle = 0
			wait(0.5)
			door.CanCollide = true
			doorDebounce = false
		end
	end)
end
function MakeWeldDoor(hinge, door)
	local doorMotor = Instance.new("Motor6D", car)
	doorMotor.Name = hinge.Name .. "Motor"
	doorMotor.Part0 = door
	doorMotor.Part1 = hinge
	doorMotor.C1 = hinge.CFrame:inverse() * door.CFrame
	door.CanCollide = false
end

function GetCFrame(object) --we'll get a CFrame value out of a CFrameValue or a StringValue formatted like a CFrame
	if object:IsA("CFrameValue") then --if someone is using a CFrame value then we'll just pull the value directly
		return object.Value
	elseif object:IsA("StringValue") then --added functionality for this because I dislike interfacing with CFrame values
		local cframe = nil
		pcall(function() --using pcall because i'm lazy
			cframe = CFrame.new(object.Value:match("(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+)"))
			--if you print your CFrame and paste it into the string value, this will find that out and use it properly
		end)
		return cframe
	end
end

for _, h in pairs(car:GetChildren()) do
	if h:IsA("Motor6D") then --make sure we start with a blank slate
		h:Destroy()
	end
end

for _, i in pairs(car:GetChildren()) do
	if i:IsA("BasePart") and i.Name:find("DoorHinge") then -- found a door with regex!
		local DoorID = i.Name:match("DoorHinge(.*)") --haha regex is fun
		local MatchingDoor = car:FindFirstChild("Door" .. DoorID) --can we use our regex powers to find a matching door?
		if MatchingDoor then -- yay we found one!
			local DoorCFrameValue = MatchingDoor:FindFirstChild("DoorCFrame")
			local HingeCFrameValue = MatchingDoor:FindFirstChild("HingeCFrame")
			if DoorCFrameValue and HingeCFrameValue then
				local doorCFrame = GetCFrame(DoorCFrameValue)
				local hingeCFrame = GetCFrame(HingeCFrameValue)
				if doorCFrame and hingeCFrame then
					MakeDoor(i, MatchingDoor, hingeCFrame, doorCFrame)
				else
					MakeWeldDoor(i, MatchingDoor)
				end
			else
				MakeWeldDoor(i, MatchingDoor)
			end
		end
	end
end

if Base then
	if Left then
		leftMotor = Instance.new("Motor6D", car)
		leftMotor.Name = "LeftMotor"
		leftMotor.Part0 = Left
		leftMotor.Part1 = Base
		leftMotor.C0 = CFrame.new(-WheelSize / 2 - Left.Size.x / 2, 0, 0) * CFrame.Angles(math.pi / 2, 0, -math.pi / 2)
		leftMotor.C1 = CFrame.new(Base.Size.x / 2 + Left.Size.x + WheelSize / 2, 0, 0)
			* CFrame.Angles(math.pi / 2, 0, math.pi / 2)
		leftMotor.MaxVelocity = motorSpeed
	end
	if Right then
		rightMotor = Instance.new("Motor6D", car)
		rightMotor.Name = "RightMotor"
		rightMotor.Part0 = Right
		rightMotor.Part1 = Base
		rightMotor.C0 = CFrame.new(-WheelSize / 2 - Right.Size.x / 2, 0, 0) * CFrame.Angles(math.pi / 2, 0, math.pi / 2)
		rightMotor.C1 = CFrame.new(-Base.Size.x / 2 - Right.Size.x - WheelSize / 2, 0, 0)
			* CFrame.Angles(math.pi / 2, 0, math.pi / 2)
		rightMotor.MaxVelocity = motorSpeed
	end
end
