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

How do i detect if a part has a part under it?

Asked by
Kennqu 3
4 years ago
Edited 4 years ago

I am relatively new to roblox scripting, and I am making a terrain generation Script. I have looked up how to do it but no results. This would be really helpful because I need dirt to be under grass. Here is my script

--Variables--

mapxsize = 256
mapysize = 32
mapzsize = 256
seed = math.random(0, 1000000)
noisescale = 30 
amplitude = 20
blocksize = 2 

--The Script--

for x = 0,mapxsize do
    for z = 0,mapzsize do
        for y = 0,mapysize do
            xnoise = math.noise(y/noisescale,z/noisescale,seed)*amplitude
            ynoise = math.noise(x/noisescale,z/noisescale,seed)*amplitude
            znoise = math.noise(x/noisescale,y/noisescale,seed)*amplitude

            density = xnoise + ynoise + znoise + y

            if density < 18 and density > 12 then
                part = Instance.new("Part",workspace.TerrainFolder)
                part.Anchored = true
                part.Size = Vector3.new(blocksize,blocksize,blocksize)
                part.CFrame = CFrame.new(x*blocksize,y*blocksize,z*blocksize)

            end
        end
    end
    wait()
end


1
Yea. umm.... if your new to scripting doing something advanced IS NOT gonna help you, its gonna discourage instead. So start doing way easier stuff then progress fowards. You are most likely not gonna get help if you don't even try. 123nabilben123 499 — 4y
0
Wow! I kind of agree with 123nabilben. A terrain generating script is pretty advanced. I have been coding for over a year, and I still can't think of an approach. greenhamster1 180 — 4y
0
I think there was a tutorial about random terrain generation in game called Lua learning By Boatbomber Yuuwa0519 197 — 4y
0
you making minecraft? skeeBarr 14 — 4y

Answer this question