So I want to duplicate a model of an R15 rig, and then I want to move the position of all the parts that can have their position moved. I started using an in pairs
loop to get all the parts. But then I don't know what to do from there. I was thinking maybe doing every part that can be moved in the model and teleporting it, but that can't be efficient.
This is the script I'm thinking of:
--Sorry for the sloppy script for i,v in pairs(Cv:GetChildren()) do if v.Name == "LeftFoot" then v.Position = game.Workspace.EnemySpawn.Position end if v.Name == "RightFoot" then v.Position = game.Workspace.EnemySpawn.Position end if v.Name == "LeftLowerArm" then v.Position = game.Workspace.EnemySpawn.Position end if v.Name == "LeftUpperArm" then v.Position = game.Workspace.EnemySpawn.Position end if v.Name == "RightLowerArm" then v.Position = game.Workspace.EnemySpawn.Position end if v.Name == "RightUpperArm" then v.Position = game.Workspace.EnemySpawn.Position end if v.Name == "LeftHand" then v.Position = game.Workspace.EnemySpawn.Position end if v.Name == "RightHand" then v.Position = game.Workspace.EnemySpawn.Position end end
I was just wondering if the fine people of scripting helpers could help me find a more efficient way. Thank you for your time.
If you just want to move the model you can move it by moving the PrimaryPart. If you don't have a PrimaryPart set, you can do it from the Properties editor in studio, or via a script (model.PrimaryPart = part).
Then you can do model:SetPrimaryPartCFrame(CFrame.new(x, y, z)) to give it a new Position or if you want to move it by x in a specific direction:
model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() + Vector3.new(xOffset, yOffset, zOffset))
Hope this answered your question.