Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
2
Answered by 3 years ago
Edited 3 years ago

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

1
That is my initial thought process. It probably is flawed. Dehydrocapsaicin 483 — 3y
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;;; Omq_ItzJasmin 666 — 3y
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! Dehydrocapsaicin 483 — 3y
Ad
Log in to vote
0
Answered by
Speedmask 661 Moderation Voter
3 years ago

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

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 Omq_ItzJasmin 666 — 3y

Answer this question