-
What do you want to achieve?
Keep the seat in the prior position after the plane model is prepared. -
What is the issue?
The seat jumps to random positions instead of staying where it should -
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!
