3

I want to make a Roblox game with multiple scenes that you can load your character into.

The problem with this is that I cannot find any way to do this. I’ve done a reasonable amount of research online, but all I get are guides on how to load a character once using a plugin, rather than getting the person who joined’s character and loading it into a certain position.

How to get the person who joined’s character and load it into a certain position?

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
Buzzyy
  • 111
  • 14
  • 1
    Could you elaborate on what you are looking to do? Are you trying to get a copy of the player's character that isn't attached to them? Are you trying to spawn them in a specific location? Are you trying to defer spawning their character so you can control when people drop into the game? – Kylaaa Nov 30 '21 at 19:04
  • @Kylaaa Yes, I’m trying to get a copy of their character that isn’t actually their controllable player, rather just a model that copies their character in a certain position; but remember, I want it to be able to change depending on the player that joins (1 player server) – Buzzyy Dec 01 '21 at 08:23
  • 1
    You can use RemoteEvents to get the LocalPlayer.Character and send that data to the server, cloning it and then positioning the HumanoidRootPart where you want it. – Cmb Feb 21 '22 at 16:56

1 Answers1

1

To create somebody's character, call Players:CreateHumanoidModelFromUserId with the Player's UserId. Then you can move it by calling PivotTo on their HumanoidRootPart.

Note: do not use Model.PrimaryPart to grab the HumanoidRootPart. On R6 characters, this is actually the character's Head. You're better off calling FindFirstChild("HumanoidRootPart") (or WaitForChild).

You'll notice that this positions the character from their torso's center, and not from their feet. So you'll need to offset that vertically by 3 studs if the character is not Rthro (is of fixed size, like R6). If the character is Rthro (is R15, and your game has scaling enabled), then you'll need to call GetExtentsSize on the character Model.

So, something like:

local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
    
local function loadStage(player: Player)
    -- ...
    local character = Players:CreateHumanoidModelFromUserId(player.UserId)
    local rootPart = character:FindFirstChild("HumanoidRootPart")

    -- assuming R6 this will be fine
    rootPart:PivotTo(CFrame.new(myDesiredPosition + Vector3.yAxis * 3))

    rootPart.Parent = Workspace
    -- ...
end

Players.PlayerAdded:Connect(function(player)
    loadStage(player)
end)
tacheometry
  • 38
  • 1
  • 6