Happy new years to all of you! I’m a bit stuck on something.
As seen in the video below, when I equip / Unequip the sword, The position changes randomly and I don’t really know how I’d fix this. Could someone explain what’s happening here and how I’d resolve it? My assumption is that I would need to lock a specific Axis but i’m unsure if this would be the best way of doing it:
Also, if you know, could you tell me a good way of moving parts that attach to the player? I’m trying to have the sword be picked up at the handle of it but will usually just copies its previous position. Thank you!
hello!
i think the problem is most likely you changing Sword.Orientation to Vector3.new(-45, -90, 0) in the FormUpdate() function. Sword.Orientation will always be set to Vector3.new(-45, -90, 0), even if that isn’t the orientation of the torso, causing the sword to be offset.
you have 2 options here:
you could either
make “BackProxy” an attachment, which will always update its rotation to the torso when parented to it (recommended, because then you can just set the sword CFrame to the attachment WorldCFrame)
simply make the sword orientation the same as the torso orientation.
Thanks for responding. After testing, it actually did solve half of the issue, thanks! Now, My next issue is that I don’t know how i’d approach rotating / moving the weapons while keeping their position the same. my previous script did this but caused the issue above too so how would I approach this correctly?
As seen, the sword retains its correct position but in an undesired way
It is a single mesh, I should’ve clarified that, apologies, but it does have a few parts as children (the parts emitting particles) so i figured it also counts as a model
alright!
i think using animations would work well.
just have 1 animation where the sword is is unequipped (presumably at the back), and 1 animation holding the sword.
to animate it, copy your character when the sword is unequipped (the sword attached the torso) and copy your character when the sword is equipped (the sword attached to the right arm).
make sure you set the animation priority to “action” or higher(i cant tell you enough how many times i’ve messed this up)
if you would prefair the sword to actually be rotated manually with code or have any issues, lemme know!
rotating (and correctly positioning) the sword manually with code would be easiest to do with attachments.
you could make one attachment on the bottom of the right arm (since this is R6) for when the sword is equipped, and one at the back of the torso for when it is not.
i know you are using a custom rig, so adding the attachments is as simple as positioning and rotating the sword and then copy and pasting the position and orientation into an attachment parented to the arm/torso. (make sure you are copying into the WorldPosition and WorldOrientation properties and not the regular Position and Orientation properties.)
im not entirely sure how you are positioning the sword currently, but if you are still using welds, i think you can set the C1(presuming thePart1property of your weld is the sword) to the CFrame of the unequipped/equipped attachment.
to change the sword between being unequipped and equipped, you can use this:
local torsoAttach = char.Torso.SwordAttach --Used when unequipped
local handAttach = char.RightArm.SwordAttach --Used when equipped
--[[ Sword is Unequipped ]]--
SwordWeld.C1 = torsoAttach.CFrame
--[[ Sword is Equipped ]]--
SwordWeld.C1 = handAttach.CFrame
using animations would probably be overall better in this case, but either will probably work the same .
I am welding parts to different parts of the player then applying an offset to them so they are positioned where I want then setting the sword’s Position to those when needed, but I can just add attachments to these parts and have the sword act on those like you said. (these will be invisible when I’m done with them)
I’ll return after I implement what you have suggested and see how it goes, thanks!
Apprently I can’t assign Attachments or their properties to welds (their Part0/1 proprery), they return with errors, according to the errors, welds can only attach to objects / baseparts
i see…
the fact that you have parts where you want the swords position makes it ALOT easier.
you could just set the SwordWeld C1 as the same as (for example the right arm’s part’s weld)'s C1 instead.
then you don’t need anything extra!
let me know if this works again, because im not entirely sure why it wouldn’t allow you to set the C1 of a weld to the CFrame of an attachment.
good luck!
The method I find is the best for this is taking advantage of the player’s attachments. You can use the attachments on a player’s character to attach models to the character model, then welding each of model’s parts together and unanchoring them. For a better understanding I left this reply that best explains this concept: