Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you change a character to a part?

Is there a script to change a character into a part and back to their character, like in PropHunt? Thanks -WiseDumbledore

1 answer

The easiest way of doing this is below. (Not the same way it is done in prop hunt, but it can work) MeshType list: MeshType Enum list

Paste the below code into a LocalScript placed in StarterGui

local Plr = game.Players.localPlayer
local MeshName = 'CharMesh'
repeat wait() until Plr.Character
wait()
local Char = Plr.Character

function charToMesh(Type, Id, Tex, Size) -- string 'type'; string or number 'Id'; string or number 'Tex'; Vector3 'Size';
-- Remember, everything I say below about changing the Mesh properties, change them in the arguments when calling the function, not here
	local MeshType = Type -- MeshTypes = {'FileMesh'; 'Brick'; 'Cylinder';} (For more on MeshTypes, see link at top of post)
	local MeshId = Id -- Leave blank if you are not using a FileMesh, otherwise input the mesh Id (just the Id, not the website stuff)
	local Texture = Tex -- Leave blank if you are not using a FileMesh or don't want a texture, otherwise input the asset Id (just the Id, not the website stuff)
	local Scale = Size -- Scale it to your liking, (offline mode is the best way to get the scale right. Test>Play Solo)
	local Mesh = Instance.new('SpecialMesh')

	for  _,v in pairs(Char:GetChildren()) do
		if v:IsA('BasePart') and v.Name ~= 'Torso' then
			v.Transparency = 1
			if v.Name == 'Head' then
				v.face.Transparency = 1
			end
		end
	end

	Mesh.Parent = Char.Torso
	Mesh.Name = MeshName
	Mesh.MeshType = MeshType
	if MeshType == 'FileMesh' then
		Mesh.MeshId = 'http://www.roblox.com/asset/?id='..MeshId
		if Texture ~= '' then
			Mesh.TextureId = 'http://www.roblox.com/asset/?id='..Texture
		end
	end
	Mesh.Scale = Scale
end

function meshToChar()
	for  _,v in pairs(Char:GetChildren()) do
		if v:IsA('BasePart') then
			v.Transparency = 0
			if v.Name == 'Head' then
				v.face.Transparency = 0
			end
		end
	end

	if Char.Torso:FindFirstChild(MeshName) then
		Char.Torso[MeshName]:Destroy()
	end
end

Example of calling charToMesh function: charToMesh('FileMesh', '1594167', '', Vector3.new(4.5, 4.5, 4.5) < Turns character into a giant grey teapot c:

Example of calling meshToChar function: meshToChar() < Just like that

Hope this helps c:

  • Nen

This discussion is preserved as it was. New answers, comments, and votes are closed.