So, I have a script that is supposed to move the sword to the correct spot. Model.Pos
is an attachment object which stores the position and rotation offsets of the weapon to position it correctly.
Here is my code that is supposed to be positioning the object correctly:
-- Parent the model
local Handle = User.Handle
Model.Anchored = true
-- Position the model
Model.CFrame = Handle.CFrame
Model.Position += Model.CFrame.LookVector * Model.Pos.Position
-- Rotate the model the model
Model.CFrame = Model.CFrame * CFrame.Angles(
math.rad(Model.Pos.Orientation.X),
math.rad(Model.Pos.Orientation.Y),
math.rad(Model.Pos.Orientation.Z)
)
-- Weld the model
Model.Anchored = false
local Constraint = Model:FindFirstChild("Constraint")
Constraint.Part1 = Handle
-- Parent the model
Model.Parent = Handle
The rotation part is fine, but the positioning part isn’t. I am trying to make it position a sword correctly. Here are two images that show the problem.
Rotated at a degree dividable by 180:
Rotated at a degree not perpendicular to a 180 degree:
Sorry for bad wording.
Thanks!