Random Position Module

Hello.

What is it?

This is a Random Position Module. Easily replacing the old fashioned way of changing part’s position to a random position. Instead of getting their X,Y, and Z values, you can create a part, and the module will automatically choose a random position inside the part. Its a really simple code, but it saves the effort of doing the math and such.

how to use it

First, you require the Module. Its recommended the Module is placed in ReplicatedStorage, or Server Script service. Here is how you can require the module if its in ReplicatedStorage

local RandomPositionModule = require(game:GetService("ReplicatedStorage"):WaitForChild("RandomPositionModule"))

and then to use the module, you just call the Module, and then put the 2 parameters. The first is which part will contain the random Positions, and second is which part will go to a random Position.
This is done like so.

local RandomPositionModule = require(game:GetService("ReplicatedStorage"):WaitForChild("RandomPositionModule"))
RandomPositionModule:RandomPosition(workspace.RandomPositionArea,workspace.Part)

This module is INCREDIBLY simple. Yet very useful. Here is the link to grab it:
https://www.roblox.com/library/6060353074/RandomPositionModule
If you find any issues, or want to tell me and recommendations, just Reply.

4 Likes

Does it work with rotated parts and different part types such as cylinders, spheres and wedges? That’d make it a lot more useful.

2 Likes

Like it chooses a random Rotation? Or do you mean it stays the same rotation when its position is changed.

I’ve not checked how the module works, but I mean if you rotate the selected part that you want a random position chosen within it, will the boundaries stay inside the part, or will it be based just on the size and position of the part? Is rotation taken into account when a random position is chosen?

it will be based soley on Position. I might make options to make random rotation, size, color, ect