How to random position for part in part

You need to study Vector3’s.

Here’s an example:

local part ="Part", workspace)
part.Position =, math.random(10),math.random(10))

Ummm i mean i wanna get random position inside part for part


Depends on what is the size of the part.

1 Like

Oh simply use constraints for your random position:
Basically what you will want to do is set your “default point” at your parts Vector3 position then use the size of each of the part’s vertices in your math.random().

1 Like

Uhh sorry i don’t understand…

1 Like

    local Part = game.Workspace.Part

    local PartMoving = game.Workspace.PartMoving

    PartMoving.CFrame = Part.CFrame *, Part.Size.X/2),math.random(-Part.Size.Y/2, Part.Size.Y/2),math.random(-Part.Size.Z/2, Part.Size.Z/2))

This will position the part in the center of the outside part like so

then it will add the size of the outside brick divided by 2 like so

this should work for what you need but it doesn’t account for the size of the inside brick

NewPart.CFrame = OutSizePart.CFrame*, OutSidePartSize.X/2), math.random(-(OutSidePartSize.Y/2), OutSidePartSize.Y/2), math.random(-(OutSidePartSize.Z/2), OutSidePartSize.Z/2))

Its a bit similar to the solution in this thread Random gems spawn

There are many people are answered, i don’t know i will mark who as solution.

I believe it gets even more complicated if you’re working in negative quadrants so you’ll need to include the absolute value of some variables.

if you go off the cframe of the first part it doesn’t matter if it’s negative or not

Yeah I just saw your answer, it should be the proper solution!

But i wanna use MoveTo() i don’t know how i can use your solution because i’m confused.

You are moving a humanoid to a random position ?

No i’m doing random meteor falling position i think i’m ok now but i don’t know how to convert CFrame to Vector3


local x =,2,3)
print("CFrame = "..x)
local y = x.p
print("Vector3 = "..y)

Error: > ServerScriptService.GameScript:280: invalid argument #1 to ‘new’ (Vector3 expected, got CFrame)

Code on that line:

m:MoveTo( Part.CFrame *, Part.Size.X/2),math.random(-Part.Size.Y/2, Part.Size.Y/2),math.random(-Part.Size.X/2, Part.Size.X/2))).Position )

Doesn’t include the MoveTo but it is what it is Make blocks fall in random positions within the area of a block

On the third parameter of the CFrame, shouldn’t it be Z. If it is, then may you change it so nobody gets confused?

(I know that I’m late to the post)

1 Like