Using custom character meshes for R15

function classesManager:GiveClass(player)
	local class = dataManager:GetClass(player)
	if class then
		local character = player.Character
		if character then
			local humanoid = character.Humanoid
			if not humanoid then return end
			for _, v in ipairs(classes:FindFirstChild(class).Armour:GetChildren()) do
				character[v.Name].MeshId = v.MeshId -- Error here
			end
   		end
	end
end

I’m trying to eventually use a custom created character mesh for my game that has all the R15 parts (bar HumanoidRootPart and Head) and my plan was that I could surely just change the current MeshId of the characters body part to the MeshId of the custom mesh. I got this error:

[Unable to assign property MeshId. Script write access is restricted]

No clue what it means, never had this error before.

I’ve looked around here as well as the Developer Hub. Applying R15 packages to characters seems a lot more tedious than R6 and from what I’ve seen, requires massive modules/scripts to get all the parts and put them on the character and scaling and attachments, etc.

The major problem with a lot of these though is they use InsertService and AssetService (to get already existing packages) but since mine is custom I can’t use that.

Secondly, the code just takes up a lot of space and I can’t understand any of it :sweat_smile: I’d like to keep it basically as small and as simple as possible. 1 function like above would be absolutely lovely :smiley: but I don’t know if that is possible :confused: If anyone can explain what the error means, way around, etc. That would be great :smiley:

Or if there is a better way (that does not involve several functions :sweat_smile:) then please tell me :weary:

Check out the Humanoid:ReplaceBodyPartR15() method.

Similar to my method that I use to load characters in my Load Character plugin, you can simply loop through the character, find the limb Enum, use that as the first parameter, and then put your custom limb in the second parameter.

Warning: I do not know how this method preforms with custom packages, as I have only used it with official Roblox bundles.

4 Likes

This is the error, no clue what this means either :sweat_smile:
[Unable to cast Instance to token]

function classesManager:GiveClass(player)
	local class = dataManager:GetClass(player)
	if class then
		local character = player.Character
		if character then
			local humanoid = character.Humanoid
			if not humanoid then return end
			for _, v in ipairs(classes:FindFirstChild(class).Armour:GetChildren()) do
				humanoid:ReplaceBodyPartR15(character[v.Name], v)
			end
		end
	end
end

The first argument takes an Enum, not an Instance.

You’ll need to make it Enum.BodyPartR15[v.Name]

Ok well that works… kinda :sweat_smile:

No errors, but only 1 character gets ‘morphed’ not the other. Could it have something to do with the for loop?

Perhaps it literally uses the second argument as its replacement. Inside of ReplaceBodyPartR15(), change the v to v:Clone()