How would I make it so I can generate sand in a modulescript?
I’m basically making a mining simulator, and need help with the sand generation. if you go in mining simulator, and you see the different types of sand in different positions, you’ll see it. I also have rich sand which has a 35% chance out of 100 to spawn in normal sand
I have a folder of parts I want in a certain position, what I basically do is:
-go thru every part in the folder
-Clone the part and parent it to workspace
-Color it
-name it
I have multiple names and certain positions, here’s the module:
local items = { -- 4,4,4 block size
["Sand"] = {
color = "Daisy orange";
pos = {738.005, 710.005}; -- top y, low y, the first variable is the beginning Y value, the other variable is the end value
coins = 1;
exclusiveChance = {
name = "Rich Sand";
color = "New Yeller";
chance = {40,100};
coins = 2;
}
},
["Grey Sand"] = {
color = "Medium stone grey";
pos = {706.005, 666.005};
coins = 3;
},
["Pink Sand"] = {
color = "Hot pink";
pos = {662.005, 618.005};
coins = 5;
},
["Blue Sand"] = {
color = "Lapis";
pos = {614.005, 578.005};
coins = 6;
},
["Green Sand"] = {
color = "Lime green";
pos = {574.005, 530.005};
coins = 15;
},
["Orange Sand"] = {
color = "Deep orange";
pos = {526.005, 442.005};
coins = 25;
},
["Cyan Sand"] = {
color = "Cyan";
pos = {438.005, 302.003};
coins = 30;
},
["White Sand"] = {
color = "Institutional white";
pos = {298.003, 210.003};
coins = 45;
},
["Black Sand"] = {
color = "Really black";
pos = {206.002, 122.001};
coins = 60;
},
["Red Sand"] = {
color = "Really red";
pos = {118.001, 6};
coins = 85;
}
}
return items
math.randomseed(tick())
local players = game:GetService("Players")
local deb = game:GetService("Debris")
local rep = game:GetService("ReplicatedStorage")
_G.playerEffects = {}
local mods = rep.modules
local sandTypes = require(mods.sandTypes)
_G.generatedSand = {}
wait(10)
for i,v in pairs(game:GetService("ServerStorage").spawns:GetChildren()) do
if v.Position.Y <= 738.005 and v.Position.Y >= 710.005 then
local part = Instance.new("Part", workspace)
part.Size = Vector3.new(4,4,4)
part.Position = v.Position
part.Anchored = true
part.TopSurface =Enum.SurfaceType.Smooth
part.BrickColor = BrickColor.new(sandTypes.Sand.color)
end
end
math.randomseed(tick())
local players = game:GetService("Players")
local deb = game:GetService("Debris")
local rep = game:GetService("ReplicatedStorage")
_G.playerEffects = {}
local mods = rep.modules
local sandTypes = require(mods.sandTypes)
_G.generatedSand = {}
wait(10)
for i,v in pairs(game:GetService("ServerStorage").spawns:GetChildren()) do
if v.Position.Y <= 738.005 and v.Position.Y >= 710.005 then
local part = Instance.new("Part", workspace)
part.Size = Vector3.new(4,4,4)
part.Position = v.Position
part.Anchored = true
part.TopSurface =Enum.SurfaceType.Smooth
local raritynumber = math.random(0,100)
if raritynumber >= 0 and raritynumber <= 35 then
part.BrickColor = BrickColor.new(sandTypes.Sand.exclusiveChance.color)
else
part.BrickColor = BrickColor.new(sandTypes.Sand.color)
end
end
this will generate a number between 0 and 100, and if its between 0 and 35, it will make it rich sand.
I messed up on the actual generation, thats what I need help with, I can do the random rich sand chance, but here’s the picture of the issue:
It’s a block down when its supposed to fully fill the top