Getting a rather odd error

Hello there! I’m AlphaEpsilon290. I edited More like rescripted an open-source chassis to make it play more nicely with NPCs that use the VehicleSeat ThrottleFloat and SteerFloat properties. Unfortunately, I get this error when using this file (250.1 KB)


Expected BasePart got Model for WeldConstraint:Part1
13:08:28.721 - Stack Begin
13:08:28.722 - Script 'Workspace.Chevy Caprice.VehicleSeat.ChassisMainEdited', Line 33
13:08:28.724 - Stack End

I’m using this chassis. If anyone could help me, that would be appreciated.

EDIT

Here's the code I think is being problematic:
for i, Descendant in pairs(Car:GetDescendants()) do
	if Descendant:IsA("BasePart") then
		if Descendant:FindFirstAncestor("Body") then
			local Weld = Instance.new("WeldConstraint", Welds)
			Weld.Part0 = Descendant
			Weld.Part1 = CarEngine
		end
		if Descendant.Name == "Holder" and not Descendant:FindFirstAncestor("Body") then
			local Weld = Instance.new("WeldConstraint", Welds)
			Weld.Part0 = Descendant
			Weld.Part1 = CarEngine
		end
		if Descendant:FindFirstAncestor("Wheel") then
			local Wheel = Descendant:FindFirstAncestor("Wheel")
			local Weld = Instance.new("WeldConstraint", Welds)
			Weld.Part0 = Descendant
			Weld.Part1 = Wheel
			Wheel.Transparency = 1
			Descendant.Anchored = false
		end
	end
end

So as the error states, you’re setting a weldConstraints Part1 to a Model. It has to be a BasePart. Perhaps you want to use Model.PrimaryPart, or an actual part inside the model.

No, I filtered out any non-BaseParts with the Instance:IsA("BasePart") function.

Not according to the statement. On line 29 write:

if Descendant:FindFirstAncestor("Wheel")
   local Wheel = Desendant:FindFirstAncestor("Wheel").PrimaryPart -- wheel is a model
end

I’m sorry for disagreeing, but I beg to differ:
image

What line is it on?
Weld.Part1 = CarEngine
or
Weld.Part1 = Wheel

For some reason, Roblox Lua seems to think that I want to set a Weld’s PrimaryPart to a Model despite the fact that Wheel is a BasePart. Non-BaseParts are filtered out on line 18.

Edit the code to check that the wheel is a BasePart because it says that’s the line that’s erroring. The Desendant has a check for that but not the wheel.

No, the wheel variable is the parent of the descendant, so it is not filtered out. Have tried checking what descendant is?

Thanks! Implementing a quick check in the script seems to have fixed the error.