Strange Vehicle Seat Behaviour

  1. What do you want to achieve?
    Keep the seat in the prior position after the plane model is prepared.

  2. What is the issue?
    The seat jumps to random positions instead of staying where it should

  3. What solutions have you tried so far?

  • storing then restoring the seats cframe
  • welding the seat to a basepart as an anchor part first, then welding everything else
  • task.wait() up to .1 seconds before unanchoring the seat

It’s worth noting that the rotation that it snaps to when you hop onto the seat is the same as the look vector of the root part!

This code is ran to create attachments for servo joints and weld together all the parts of the plane, which at that point is just anchored parts. It is called when the player is sat down, and on the server the network ownership is given to the player who sat. No remote events are involved in that process. :))

Photo showing the issue:

(the seat is supposed to be flush with the surface of the plane behind that little visor)

function Preparation:PreparePlane()
	local basePart = self.parent.Utilities.FindFirstDescendantWhichIsA(self.parent.plane, "VehicleSeat")
	if not basePart then return end
	
	if self:Check() then return end
	
	basePart.Anchored = false
	
	for index, descendant in self.parent.plane:GetDescendants() do
		if descendant:IsA("BasePart") and descendant ~= basePart then
			local objectData = self.parent.ObjectData[descendant.Name]

			local objectType = objectData and objectData.objectType or nil
			if objectType == "controlSurface" then
				local attachment = descendant:FindFirstChild("Attachment")
				local hinge = descendant:FindFirstChild("HingeConstraint")
				if not attachment or not hinge then continue end
				
				local bodyAttachment = Instance.new("Attachment", basePart)
				bodyAttachment.WorldOrientation = attachment.WorldOrientation
				bodyAttachment.WorldPosition = attachment.WorldPosition
				
				hinge.Attachment1 = bodyAttachment
				hinge.Attachment0 = attachment
			else
				local weld = Instance.new("WeldConstraint", descendant)
				weld.Part0 = basePart
				weld.Part1 = descendant
			end
			
			descendant.Anchored = false 
		end
	end
	
	local read = self.parent.plane:GetAttribute("Prepared")
	if not read then
		self.parent.plane:SetAttribute("Prepared", true)
	end
end

Thank you!

2 Likes

Seats are a bit odd, I’ve had issues with them many times. They should be, cancollide = false, and they should have anchored = false. They work best with the weld or weldconstraint instance not being parented under them.

The issue is because you unanchor the seat before welding the rest of the parts. The SeatWeld breaks the seat to your character’s position since the assembly is loose. Simply move the unanchoring line to the bottom so it stays still while the welds are created.

function Preparation:PreparePlane()
	local basePart = self.parent.Utilities.FindFirstDescendantWhichIsA(self.parent.plane, "VehicleSeat")
	if not basePart then return end
	
	if self:Check() then return end
	
	for index, descendant in self.parent.plane:GetDescendants() do
		if descendant:IsA("BasePart") and descendant ~= basePart then
			local objectData = self.parent.ObjectData[descendant.Name]

			local objectType = objectData and objectData.objectType or nil
			if objectType == "controlSurface" then
				local attachment = descendant:FindFirstChild("Attachment")
				local hinge = descendant:FindFirstChild("HingeConstraint")
				if not attachment or not hinge then continue end
				
				local bodyAttachment = Instance.new("Attachment", basePart)
				bodyAttachment.WorldOrientation = attachment.WorldOrientation
				bodyAttachment.WorldPosition = attachment.WorldPosition
				
				hinge.Attachment1 = bodyAttachment
				hinge.Attachment0 = attachment
			else
				local weld = Instance.new("WeldConstraint", descendant)
				weld.Part0 = basePart
				weld.Part1 = descendant
			end
			
			descendant.Anchored = false 
		end
	end
	
	basePart.Anchored = false
	
	local read = self.parent.plane:GetAttribute("Prepared")
	if not read then
		self.parent.plane:SetAttribute("Prepared", true)
	end
end

Install a weld plugin .. this one looks like it will do
Use this to weld the seat from the editor. These just hold well.
A bit tricky to work with, but you’ll get it.. I use them over using a
WeldConstraint all the time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.