The script works fine, however all I want it to set the Back (which is a union) to be rotated by 180 degrees. Because when I am in the game, the union is upside down...
I have played with w.C0 = CFrame.fromEulerAnglesXYZ(0,0,0) I kept changing the cordinates inside.. all it seemed to do is rotate the Back and the Front.
How can I set the Back union to change its angle when its welded?
attachment = "Torso"
function stick(x, y)
weld = Instance.new("Weld")
weld.Part0 = x
weld.Part1 = y
local HitPos = x.Position
local CJ = CFrame.new(HitPos)
local C0 = x.CFrame:inverse() *CJ
local C1 = y.CFrame:inverse() * CJ
weld.C0 = C0
weld.C1 = C1
weld.Parent = x
end
stick(script.Parent.Back, script.Parent.Front)
function onOwnerChanged()
local attach = script.Parent.Parent.Owner.Value:findFirstChild(attachment)
if attach~=nil then
script.Parent.Back.Anchored = false
script.Parent.Front.Anchored = false
script.Parent.Parent.Parent = attach.Parent
local w = Instance.new("Weld")
w.Parent = attach
w.Part0 = script.Parent.Front
w.Part1 = attach
w.C0 = CFrame.new(0, -0.7, 0) * CFrame.fromAxisAngle(Vector3.new(0,1,0),math.pi/2) * CFrame.fromAxisAngle(Vector3.new(1,0,0),math.pi/2)
end
end
script.Parent.Parent.Owner.Changed:connect(onOwnerChanged)
