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:
02 | game.Players.PlayerAdded:Connect( function (player) |
03 | player.Chatted:Connect( function (msg) |
04 | if string.lower(msg) = = "/r6" then |
06 | elseif string.lower(msg) = = "/r15" then |
changeRig script in startercharacterscripts:
2 | if _G.r 6 = = false and script.Parent.Parent.Parent.Humanoid.RigType = = Enum.HumanoidRigType.R 6 then |
3 | script.Parent.Parent.Parent.Humanoid.RigType = Enum.HumanoidRigType.R 15 |
4 | elseif _G.r 6 = = true and script.Parent.Parent.Parent.Humanoid.RigType = = Enum.HumanoidRigType.R 15 then |
5 | script.Parent.Parent.Parent.Humanoid.RigType = Enum.HumanoidRigType.R 6 |
updated:
02 | if _G.r 6 = = false and script.Parent.Humanoid.RigType = = Enum.HumanoidRigType.R 6 then |
03 | local pastChar = script.Parent |
04 | pastChar.Archivable = true |
05 | local newChar = pastChar:Clone() |
06 | newChar.Parent = workspace |
07 | newChar.Humanoid.RigType = Enum.HumanoidRigType.R 15 |
08 | local description = game.Players:GetHumanoidDescriptionFromUserId(game.Players:GetPlayerFromCharacter(script.Parent).UserId) |
09 | newChar.Humanoid:ApplyDescription(description) |
10 | repeat wait() until game.Players:GetPlayerFromCharacter(script.Parent) |
11 | game.Players:GetPlayerFromCharacter(script.Parent).Character = newChar |
12 | game.Players:GetPlayerFromCharacter(script.Parent).Camera.CameraSubject = newChar.Humanoid |
13 | game.Players:GetPlayerFromCharacter(script.Parent):LoadCharacter() |
14 | elseif _G.r 6 = = true and script.Parent.Humanoid.RigType = = Enum.HumanoidRigType.R 15 then |
15 | local pastChar = script.Parent |
16 | pastChar.Archivable = true |
17 | local newChar = pastChar:Clone() |
18 | newChar.Parent = workspace |
19 | newChar.Humanoid.RigType = Enum.HumanoidRigType.R 6 |
20 | local description = game.Players:GetHumanoidDescriptionFromUserId(game.Players:GetPlayerFromCharacter(script.Parent).UserId) |
21 | newChar.Humanoid:ApplyDescription(description) |
22 | game.Players:GetPlayerFromCharacter(script.Parent).Character = newChar |
23 | repeat wait() until game.Players:GetPlayerFromCharacter(script.Parent) |
24 | game.Players:GetPlayerFromCharacter(script.Parent).Camera.CameraSubject = newChar.Humanoid |
25 | game.Players:GetPlayerFromCharacter(script.Parent):LoadCharacter() |