XRig is a Module that lets you change the Rig Type of a Player’s Avatar Mid-Game. It is a simple yet useful Module , it can be used for things such as admin commands (:r6 ; :r15) , skins that don’t have the same rig type , and many more!
XRig is a simple Module , so it contains only one function : change_rig_type()
That function takes 2 parameters : player (a Player) , and rig_type (R15 or R6 , it must be a string)
example of usage :
local XRig = require(game:GetService(“ServerScriptService”).XRig)
XRig.change_rig_type(target, “R6”)
example of usage in code :
This is the first ressource that i post on the DevForum , so let me know if i did anything wrong.
Well the module is a great idea. However, you can update it. First you can add advanced type on your parameter rig_type, you can create a variable Players. You can also check if the player exist. You can just use return function and rework the R6 and R15 condition.
Before
local XRig = {}
function XRig.change_rig_type (player : Player, rig_type : string)
if rig_type == "R6" then
rig_type = Enum.HumanoidRigType.R6
elseif rig_type == "R15" then
rig_type = Enum.HumanoidRigType.R15
end
local humanoid_description = game.Players:GetHumanoidDescriptionFromUserId(player.CharacterAppearanceId)
local new_rig = game.Players:CreateHumanoidModelFromDescription(humanoid_description, rig_type)
new_rig:SetPrimaryPartCFrame(player.Character.PrimaryPart.CFrame)
new_rig.Name = player.Name
player.Character = new_rig
new_rig.Parent = workspace
end
return XRig
After
local Players = game:GetService("Players")
return function(player: Player, rig_type: "R6" | "R15" | Enum.HumanoidRigType)
assert(player:IsA("Player"), "Player does not exist")
if typeof(rig_type) == "string" then
rig_type = Enum.HumanoidRigType[rig_type]
end
local humanoid_description = Players:GetHumanoidDescriptionFromUserId(player.CharacterAppearanceId)
local new_rig = Players:CreateHumanoidModelFromDescription(humanoid_description, rig_type)
new_rig:SetPrimaryPartCFrame(player.Character.PrimaryPart.CFrame)
new_rig.Name = player.Name
player.Character = new_rig
new_rig.Parent = workspace
end
Thanks , but i don’t think that these changes would have a noticeable impact on the module overall. If there is no player , then the function won’t run anyways , so it’s useless to check if it’s a player or not.