Hello, I’m working on a project, and I’ve came across a little road-block, which I have no idea on solving. I’m trying to make a random generating structure, in one certain position. I’m trying to make the generating structure vary from three objects. Does anyone know/have a script that can do this.
I’ve searched all over and can’t find a solution so I hope someone can help here.
Thanks!
This really depends on what you expect the outcome to be.
Is this like a maze that spans indefinitely, or to a fixed grid?
Is this a tower that, every floor has a different layout?
Are you simply placing furniture about?
If you could draw up a schematic or show us the three objects you mentioned and how they might fit together, we could help.
As a starter; let’s say your objects form a tower and there’s 3 types of floors;
local floorTypes = game.ReplicatedStorage.FloorTypes:GetChildren() -- let's say these are your 3 objects
local position = Vector3.new(0,0,0) -- this is where the floors will be placed
local size = Vector3.new(30,20,30) -- let's say each floor is exactly 30x20x30 studs wide/high
for floor = 0,4 do -- 5 floors;
local newFloor = floorTypes[math.random(1,#floorTypes)]:Clone() -- choose a random floor and copy it
newFloor.Parent = workspace
newFloor:MoveTo(position + Vector3.new(0, size.Y/2 * floor, 0) -- presuming each floor is a Model, position at the next floor
end
Well I’m working on this room, where in each server it is different, similar to Game 2 in Hexa Game.
I’m going to have 1 shape the player walks across, with 3 randomized options, and I can’t find or make a script on how to make the shapes vary in different servers.
Here’s a screenshot for reference:
If the location and dimensions of the puzzle is unchanging and only spawns once, you could literally just build all three of your puzzles and place each in a Model, then put those models in Replicated or Server storage.
Then when the server starts, just randomly pick one as I mentioned before and parent it to workspace when the server starts - no positioning required.
--ServerScriptService script
local puzzles = game.ReplicatedStorage.Puzzles:GetChildren()
puzzles[math.random(1,#puzzles)].Parent = workspace
Seems as simple as that if I understand your problem right.