---------------------------
--[[
	--Main anchor point is the DriveSeat <car.DriveSeat>	
	
	Usage:
		MakeWeld(Part1,Part2,WeldType*,MotorVelocity**) *default is "Weld"  **Applies to Motor welds only
		ModelWeld(Model,MainPart)
	Example:
		MakeWeld(car.DriveSeat,misc.PassengerSeat)
		MakeWeld(car.DriveSeat,misc.SteeringWheel,"Motor",.2)
		ModelWeld(car.DriveSeat,misc.Door)
]]
--Weld stuff here

MakeWeld(car.Misc.Trunk.SS,car.DriveSeat,"Motor",.04).Name="W"
ModelWeld(car.Misc.Trunk.Parts,car.Misc.Trunk.SS)

for _,v in pairs({car.Misc.Trunk}) do
	local open=false
	for _,a in pairs(v.Parts:GetChildren()) do
		if a.Name=="Handle" then
			local CL = Instance.new("ClickDetector",a)
			CL.MaxActivationDistance = 12
			CL.MouseClick:connect(function()
				open = not open
				if open then
					a.Parent.Parent.SS.W.DesiredAngle = math.rad(60.5)
				else
					a.Parent.Parent.SS.W.DesiredAngle = 0
				end
			end)
		end
	end
end

car.DriveSeat.ChildAdded:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
		child.C0=CFrame.new(0,-.5,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0)
	end
end)
