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

How to clone a model to the positions of each player?

Asked by 8 years ago

In a game I'm working on, when a round begins, a model will be cloned at the position of each player. How exactly would I do that?

1 answer

Log in to vote
2
Answered by 8 years ago

Something along these lines:

local model = pathToTheModel

for num, player in ipairs( game.Players:GetPlayers() ) do
    if player.Character and player.Character:FindFirstChild( "Torso" ) then
        local copy = model:clone()
        copy.Parent = game.Workspace
        copy:MoveTo( player.Character.Torso.Position )
    end
end

If you want the model to be in front of player, replace the player.Character.Torso.Position with this: (player.Character.Torso.CFrame * CFrame.new( 0, 0, 5 )).p.

Also, you will have to set primary part for the model.

1
You don't actually have to set the Primary Part when using MoveTo() however, it is recommended. DevSean 270 — 8y
Ad

Answer this question