ROBLOX Forcing Player to a Rig

Disclosure
Yes, I have done my research and I have looked around on numerous threads to see if anyone else had the issue I’m running in to; in short, I couldn’t find a solution for this issue.

Issue
A relatively influental part of my game requires individuals to be able to transform in to other Rigs, allowing them to then take control, etc… (As you would expect)
In order to do this I’ve set the players character, destroyed the old character, etc…

A thread posted by @colbert2677 posted here had a response that mentioned parenting the humanoid and reconstructing the character without deleting the model, I’ve done that.

The issue at hand is that the individual who I’m changing the character for, dies, and as a result they respawn, the humanoid also doesn’t move, etc. when pressing your movement keys.

Showcase

Code

First Attempt

local character = player.Character
local humanoid = character.Humanoid
	
local model = self.Assets["Beast Titan"]:Clone()
model:SetPrimaryPartCFrame(character.PrimaryPart.CFrame * CFrame.new(0, 50, 0))
	
model.Name = character.Name
model.Parent = workspace
model.PrimaryPart:SetNetworkOwner(player)

		
player.Character = model
	
character:Destroy()

Second Attempt

local character = player.Character
local humanoid = character.Humanoid
	
local model = self.Assets["Beast Titan"]:Clone()
model:SetPrimaryPartCFrame(character.PrimaryPart.CFrame * CFrame.new(0, 50, 0))
	
model.Name = character.Name
model.Parent = workspace
model.PrimaryPart:SetNetworkOwner(player)

humanoid.Parent = self.Assets.Cache
	
for _, part in pairs(character:GetChildren()) do
	part:Destroy()
end
	
for _, child in pairs(model:GetChildren()) do
	child.Parent = character
end
	
humanoid.Parent = character
model:Destroy()

Part of CaZsm’s suggested solution was hacking the Died state off first before removing the Humanoid and gutting the character - not seeing any use of SetStateEnabled here.

I figure it’s worth noting but I never actually tested that solution and still to this day have not found a proper method to cleanly switch character rigs. So many things to do with the character are very hacky and unsupported, especially hot swapping a rig.

1 Like

That does fix the issue of the player getting killed when swapping the character, on my second attempt, however while doing this on the first attempt it doesn’t work.

Furthermore, would this reset the PlayerControls and prevent the Humanoid from being moved from your keys?

Another possible solution should be to instead of switching rigs with the bugginess involved, is to spawn in an NPC and give control of it to the player via network ownership like I did with my mech.

You can just use a seat to disable player controls and unbind the jump button. Control script on the box humanoid can be done locally as network ownership has been transferred but will also have to be done manually, for this you can use the :GetControls() from the player module then use Humanoid:Move().

For the camera you can also switch camera subject to the npc humanoid.

Plus it fits the lore better for AOT :wink: