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!