Need Assistance with Replacing Meshes via RemoteEvent

Hello,
I’m trying to replace a player’s avatar body parts with different meshes when they press a button.

Local Script:

local Button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local replaceBodyPartEvent = ReplicatedStorage:WaitForChild("ReplaceBodyPartEvent")

Button.MouseButton1Click:Connect(function()
	replaceBodyPartEvent:FireServer("Head", 2530636595)
	replaceBodyPartEvent:FireServer("UpperTorso", 2530636595)
end)

Server Script inside ServerScriptService:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local replaceBodyPartEvent = ReplicatedStorage.ReplaceBodyPartEvent

replaceBodyPartEvent.OnServerEvent:Connect(function(player, bodyPart, meshId)
	local character = player.Character
	if character then
		local part = character:FindFirstChild(bodyPart)
		if part then
			local mesh = part:FindFirstChildOfClass("SpecialMesh")
			if not mesh then
				mesh = Instance.new("SpecialMesh")
				mesh.Parent = part
				mesh.Scale = part.Size
			end
			mesh.MeshId = "rbxassetid://" .. meshId
		else
			warn("Body part not found:", bodyPart)
		end
	else
		warn("Character not found for player:", player.Name)
	end
end)

I’ll put some Prints in there that always fire, but the warnings never do, yet the avatar’s body parts remain unchanged. I used two mesh IDs from one of the Robot NPCs as an example here, but no other mesh ID seems to work either.

What am I doing wrong? Thanks!

Hi there,

You seem to be parsing an ImageId over to the server instead of a MeshId. Are you sure you’re not intending to set mesh.TextureId instead?

For character mesh changes, you’re not able to simply modify the MeshId due to it being a locked property, being a part of the player’s character. Instead, use Humanoid:ApplyDescription() containing your appropriate changes.

Thanks for the response! Admittedly, I’m shooting a bit blind here, never tried to modify a player’s mesh before, but I know it can be done at least for the StarterPlayer. Trying to apply it at the click of a button. Thanks for the link! I tweaked it a bit, still doesn’t quite work. But let me ask, would be better to change the player’s Avatar as a StaterPlayer script first? And then let the player click the button to change the TextureID?

1 Like

If you want to edit the entire player mesh, just swap out the character

local newCharacter = ...
player.Character = newCharacter