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

How Would I Find The Position of a Model?

Asked by 4 years ago

So I am trying to make a system that clones the model in a random position. Here is my script:

local spawner = game.ReplicatedStorage.SpawnCage1
local cage = game.ServerStorage.Cage:Clone()
local cage1 = cage:GetChildren()

if spawner.Value == true then
    cage.Parent = workspace
    local position1 = Vector3.new(0,0,0)
    local position2 = Vector3.new(10,0,0)   
    local position3 = Vector3.new(20,0,0)
    local position4 = Vector3.new(30,0,0)
    local chosenPos = {position1,position2,position3,position4}
    cage.Position = math.random(1,#chosenPos)
elseif spawner.Value == false then
    cage.Parent = game.ServerStorage
end

Here is the error in output: 18:23:29.929 - Position is not a valid member of Model

If someone could help me out here that would be very nice. Thanks in advance.

4 answers

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

PrimaryPart

How to set a Primary Part for a Model is quite simple... 1. You click on the model. 2. You go to PrimaryPart and click. 3. You click on a part within that model that you want to be the main position of that model. Then your part is done. So when you move your part through a script... it'll move the model as well.

1
Wow that was a quick answer lol, I literally just posted this. PrismaticFruits 842 — 4y
Ad
Log in to vote
0
Answered by
nc2r 117
4 years ago

Find the position of one of the parts, or average the positions of all of the parts.

Log in to vote
0
Answered by 4 years ago

Use Model:GetPrimaryPartCFrame().p Or Model.PrimaryPart.Position You will need to set a PrimaryPart though https://developer.roblox.com/en-us/api-reference/function/Model/GetPrimaryPartCFrame

Log in to vote
-2
Answered by 4 years ago

Make all the parts a single union and set position of the union!

0
Please Accept My Answer If It Works! EnzoTDZ_YT 275 — 4y
0
I can't because some parts have touch functions to specific objects. PrismaticFruits 842 — 4y
0
Do not union all parts, Unions are meant to be used for little edits to bricks... not for giant things. Just2Terrify 566 — 4y
0
Sorry As I Dont Know Much About Unions EnzoTDZ_YT 275 — 4y

Answer this question