How can I transfer player.Character to another model?

I’m currently testing methods to transfer a player’s control of their character to another model (with a humanoid). I’ve tried welding the player’s character to the model in question, which works, but it won’t work in every situation I have planned for my game. The best solution to this is probably to use player.Character, but I’m not really sure how I’d move that from rig to rig.

image
This is what I’ve been working on so far. Upon clicking a part, you should transfer player.Character to the rig in question starting at line 5 (which is where I’m stuck, I have no idea how to do this).

Please let me know if you have any solutions!

4 Likes

i do it by setting .Character to nil then the new character to the model u want and changing workspace.CurrentCamera.CameraSubject to the character models humanoid and you should be good to go

I tried doing this, but I got an error. Not sure how to go about fixing this… maybe I just did it wrong? image

try doing player.Character:Destroy() instead

Tried that and I somehow got the same error as before (attempt to index nil with ‘Character’)

where is the script located, bc for some reason u cant find the character of a player if the script is located inside the players character

otherwise just try setting the character without changing the previous character

Script is within the part that holds the same click detector, it’s also not a local script (not sure if that would cause a problem, though). Here’s the whole thing so far:

image

MouseClick returns the player who fires it, use it

clickdetector.MouseClick:Connect(function(player)
	player.Character = nil
end)
2 Likes

localplayer cannot be used in a regular script only in local scripts

2 Likes
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local Model = Model:Clone()
player.Character = Model
end)
1 Like

Here’s what I’ve got so far from all the help :

There are no errors that I get from this code, however, it doesn’t seem to work the way it should. Although the player’s Character is transferred, you can’t control the new character and the camera seems to stay in place. Maybe there’s something I overlooked?

Maybe because you have a variable player, which I guess it’s still not a localscript, and then the parameter which has the same name??? Delete the player variable.

1 Like

Nothing changed but I see what you mean.

The script must be from the server:

ghostcontrol = script.Parent
newshell = workspace.Dummy

local clickdetector = script.ClickDetector
clickdetector.MouseClick:Connect(function(player)
	player.Character = newshell
end)

Inside the humanoid / new character there must be a local animate script, you can do a test and copy the one of your own character, and move all the code a little down and as the first line put this

workspace.CurrentCamera.CameraSubject = script.Parent.Humanoid
6 Likes

Check If Every part inside the model of the new character is anchored including HumanoidRootPart Make sure that its Unachored or else you wouldn’t be able to control it.

1 Like

Thank you so much. This seems to work for my purposes, I’ll build on the concept from here :slight_smile:

1 Like