I’m trying to make it so a part lays flat across a players back.
For some reason, the model doesn’t lay flat, instead being randomly rotated to a different position.
I’ve tried flipping the rotation, changing the attachments rotation, and setting both attachment and part rotation to 0,0,0. None of these methods worked.
You will need to add some rotation to one of the welds C0 or C1 components. FOr example, rotating C0 based on it’s relative position to C1
-- Rotate Weld of the held Item
local rotationAngle = 90
local additionalRotation = newBow.Weld.C1:Inverse() * rotationAngle * newBow.Weld.C1
newWeld.Weld.C0 *= additionalRotation
It sounds like you need to adjust the orientation of the newBow part to make it lay flat against the player’s back. You can do this by rotating the part around its local X axis by 90 degrees. Here’s an updated version of your code that includes this modification:
--Server Script
local Character = player.Character
local Bow = game:GetService("ServerStorage").Accessories.BowModel
local newBow = Bow:Clone()
newBow.Parent = Character
-- Rotate the part so that it lays flat against the player's back
newBow:SetPrimaryPartCFrame(newBow:GetPrimaryPartCFrame() * CFrame.Angles(math.pi/2, 0, 0))
local newWeld = Instance.new("Weld")
newWeld.Part0 = newBow
newWeld.Part1 = Character.UpperTorso
newWeld.C0 = newBow.SheathedAttachment.CFrame
newWeld.C1 = Character.UpperTorso.BodyBackAttachment.CFrame
newWeld.Parent = newWeld.Part0
This code rotates the primary part of newBow (which is the part that determines the position and orientation of the entire model) by 90 degrees around its local X axis using the SetPrimaryPartCFrame method. This should cause the part to lay flat against the player’s back when it is welded to the UpperTorso .