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

How would I go about changing a humanoid's rigtype ingame?

I want players to be able to change their rigtype (r6 and r15) without going to the roblox avatar and resetting in game..is that possible? i tried a simple chatted event and used _G variables but when i want to change to r6, everytime i respawn i die again. help?

chatted script in serverscriptservice:

_G.r6 = false
game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if string.lower(msg) == "/r6" then
			_G.r6 = true
		elseif string.lower(msg) == "/r15" then
			_G.r6 = false
		end
	end)
end)

changeRig script in startercharacterscripts:

while wait() do
	if _G.r6 == false and script.Parent.Parent.Parent.Humanoid.RigType == Enum.HumanoidRigType.R6 then
		script.Parent.Parent.Parent.Humanoid.RigType = Enum.HumanoidRigType.R15
	elseif _G.r6 == true and script.Parent.Parent.Parent.Humanoid.RigType == Enum.HumanoidRigType.R15 then
		script.Parent.Parent.Parent.Humanoid.RigType = Enum.HumanoidRigType.R6
	end
end

updated:

while wait() do
	if _G.r6 == false and script.Parent.Humanoid.RigType == Enum.HumanoidRigType.R6 then
		local pastChar = script.Parent
		pastChar.Archivable = true
		local newChar = pastChar:Clone()
		newChar.Parent = workspace
		newChar.Humanoid.RigType = Enum.HumanoidRigType.R15
		local description = game.Players:GetHumanoidDescriptionFromUserId(game.Players:GetPlayerFromCharacter(script.Parent).UserId)
		newChar.Humanoid:ApplyDescription(description)
		repeat wait() until game.Players:GetPlayerFromCharacter(script.Parent)
		game.Players:GetPlayerFromCharacter(script.Parent).Character = newChar
		game.Players:GetPlayerFromCharacter(script.Parent).Camera.CameraSubject = newChar.Humanoid
		game.Players:GetPlayerFromCharacter(script.Parent):LoadCharacter()
	elseif _G.r6 == true and script.Parent.Humanoid.RigType == Enum.HumanoidRigType.R15 then
		local pastChar = script.Parent
		pastChar.Archivable = true
		local newChar = pastChar:Clone()
		newChar.Parent = workspace
		newChar.Humanoid.RigType = Enum.HumanoidRigType.R6
		local description = game.Players:GetHumanoidDescriptionFromUserId(game.Players:GetPlayerFromCharacter(script.Parent).UserId)
		newChar.Humanoid:ApplyDescription(description)
		game.Players:GetPlayerFromCharacter(script.Parent).Character = newChar
		repeat wait() until game.Players:GetPlayerFromCharacter(script.Parent)
		game.Players:GetPlayerFromCharacter(script.Parent).Camera.CameraSubject = newChar.Humanoid
		game.Players:GetPlayerFromCharacter(script.Parent):LoadCharacter()
	end
end

2 answers

I'm not really sure about this one, but maybe try cloning your character, change the clone's humanoid's RigType to R6, set the its Position to the current character's position, parent the clone character to the workspace, and set player.Character to the clone character, then :Destroy() the current character.

I found this article that might help; good luck! https://devforum.roblox.com/t/how-can-i-change-the-character-to-another-character/368670/13

3 comments

1

That is my initial thought process. It probably is flawed.

0

Thanks, but this happened: https://i.gyazo.com/ac79a313a1239c5ffe8d317905956ae0.mp4 . The camera does not lock to the player, and the clothes do not load;;;

1

Ohhh, I see. Hmmm, what about this, set Camera.CameraType to Custom and save the initial character's Shirt and Pants and apply those to your clone character. I hope this helps!

the cloning idea is halfway there, have you considered LoadCharacter()? that sounds like what you need.

1 comment

0

Thank you, but I tried that and it also did not work,, I think im doing something wrong;;;i updated my question to show the script i used

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