Positioning a Model correctly on the character, any help?

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:

Relevant parts of the script:

CurrentMode = 0
PrevMode = 0

Sword.CanCollide = false
Sword.Parent = char
SW = Instance.new("WeldConstraint")
SW.Parent = char
SW.Part0 = char.Torso:FindFirstChild("BackProxy")
SW.Part1 = Sword
Sword.Position = char.Torso:FindFirstChild("BackProxy").Position
Sword.Orientation = Vector3.new(-45, -90, 0)
Sword.BlueGlow.Position = Sword.Position + Vector3.new(1.11,1,0)

function FormUpdate(FormName, PrevForm)
	if FormName == "Dreamcaster" then
		SW.Part0 = char["Right Arm"]:FindFirstChild("RHandProxy")
		Sword.Position = char["Right Arm"]:FindFirstChild("RHandProxy").Position
		Sword.BlueGlow.Position = Sword.Position + Vector3.new(1.11,1,0)
		else
		SW.Part0 = char.Torso:FindFirstChild("BackProxy")
		Sword.Position = char.Torso:FindFirstChild("BackProxy").Position
		Sword.Orientation = Vector3.new(-45, -90, 0)
		Sword.BlueGlow.Position = Sword.Position + Vector3.new(1.11,1,0)
	end

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!

1 Like

try using cframe instead of position to position the model

1 Like

Sorry for the late reply, I was sleeping.

I’ll try that, but I’d like to know: What’s the difference between the two? Other that CFrame allows you to also change orientation

1 Like


This was the outcome of doing such, I believe that I’ve done something wrong here? All I did was change the position values to CFrame

After changing a few things, trying to equip the sword just starts an infinite pause screen

No errors too.

Thanks, but I think I’ll just go back to position. I just need to know how to keep its orientation fixed based on the torso’s orientation

1 Like

Upping this since I’ve tried a few other things which seems to have not worked. any help?

1 Like

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

  1. 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)
  2. simply make the sword orientation the same as the torso orientation.

TL;DR:
change:

Sword.Orientation = Vector3.new(-45, -90, 0)

in the FormUpdate() function
to:

Sword.Orientation = char.Torso.Orientation

let me know if that works!

2 Likes

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

is the sword a model or a single mesh?

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
image
This is the Heirarchy

1 Like

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!

Thanks, I’ll try that. I would like to hear the manual method as well though so i can use the other if one method doesn’t work

sorry for the late response :sick:

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 the Part1 property 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 :coefficients:.

1 Like

No worries, Thanks for the reply

image
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!

1 Like

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!

SW.Parent = char
SW.Part0 = char.Torso:FindFirstChild("BackProxy")
SW.Part1 = Sword.SheathAttachment.CFrame
Sword.Position = char.Torso:FindFirstChild("BackProxy").Position
Sword.Orientation = char.Torso:FindFirstChild("BackProxy").Orientation
Sword.BlueGlow.Position = Sword.Position

did I do something wrong to cause this? this is the error that comes up when trying that

SW is the weld for reference

sorry, i probably should have been more precise

you want to set the C1 to the CFrame, not the Part1

again, i should have been more specific
my mistake!

Ah, where is this property? it’s not listed:
image

It doesn’t come up when typing it in code either

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:

1 Like