How do you put equipment models on a character properly?

I’m attempting to put models onto my character like equipment.
I am using the character’s head to test my script.

You can see that the eyes and hair don’t make it onto the head at all, but instead decide to float a decent distance away from the head.
How would I make them stick to the head properly?

local function moveToCharacter(model,character)
	
	model:PivotTo(character:WaitForChild("Head").CFrame)
	
end

image

I can post the full script if needed. It’s 60 lines, so I don’t want to overwhelm, and I doubt the rest has impact on the position of the part, but do ask if you need it :slight_smile: .

The best way is to use them as Accessories. Creating an Accessory and adding the part/mesh under it, it will be positioned roughly where it needs to be when you Parent it to the character. You can then tweak the offset to align it perfectly.

this seems really unnesecary and messy. Having to upload and manage models on roblox accessories page instead of just putting my models on the character. I also think that accessories are extremely limited since from what I have seen they cannot be put into folders in the character which makes sorting impossible.

This video seemingly welds a model without even needing to teleport it and just weldconstraining it???
For me they just float in the void if I don’t teleport it, and even if I do it has a weird offset as you can see.

1 Like

I’ll give a wider scope here on how I weld the models and when the functions run. All of the parts weld as the script instructs. I’m assuming there is some kind of mistake in the process, or maybe something to do with the models themselves, but I really have no clue when tutorials don’t do anything different from what I can see.

local function moveToCharacter(model,character)
	
	model:PivotTo(character:WaitForChild("Head").CFrame)
	
end

local function addConstraints(model,character)
	
	for index,part in pairs(model:GetChildren()) do
		if part:IsA("BasePart") then
			
			local constraint = Instance.new("WeldConstraint")
			constraint.Parent = part
			constraint.Part0 = part
			
			if part.Parent.Parent.Name == "Eyes" or part.Parent.Parent.Name == "Hair" or part.Parent.Parent.Name == "Hat" then
				constraint.Part1 = character:WaitForChild("Head")
			else
				print(part)
				print("not head equipment")
			end
		end
	end
	
end

local function addHairToCharacter(character)
	
	local PlayerHairFolder = character.Equipment.Hair
	local hairClone = ReplicatedHairFolder.Hair1:Clone()
	
	hairClone.Parent = PlayerHairFolder
	moveToCharacter(hairClone,character)
	addConstraints(hairClone, character)
	
end

I believe my confusion was due to PivotTo() not being enough to center the model (?) since you can’t weld a model to the parts, making the PivotTo() a bit useless, although it is nice to have the model co-ordinates not be all over the place I suppose.

Solution: The parts in replicatedstorage need to have a specific offset prior to cloning. Edit the main part’s position (not primarypart per say) in studio before scripting, and then weld all parts together to the main part so that they follow the main part’s position.

Edit: And remember to add constraints after the positioning function is finished.

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