Attached part on players back not rotating with orientation

  1. I’m trying to make it so a part lays flat across a players back.

  2. For some reason, the model doesn’t lay flat, instead being randomly rotated to a different position.

  3. 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.

Picture of issue:

Code
--Server Script
local Character = player.Character
local Bow = game:GetService("ServerStorage").Accessories.BowModel

local newBow = Bow:Clone()
newBow.Parent = Character

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

Any help is appreciated!

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

I tried this, but it returned this error: invalid argument #2 (Vector3 expected, got number).

The line that errored was this one: local additionalRotation = newBow.Weld.C1:Inverse() * rotationAngle * newBow.Weld.C1.

Not sure what the issue was, but it seems to be possibly related to rotationAngle just being a number?

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 .

With some small changes, I made this work!

Thank you to everyone who replied :slight_smile:

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