How is the mining game system made?

I’m asking for resources, not for people to make code for me or to write systems for me. I just said that those resources could be code or already written systems out there.

Uhh a minigame making video? Are you sure it has to do with mining?

OOPS, my bad I read mining as mini game! This might help!

Sorry, but this isn’t what I am looking for. I am talking about the chunk mining system found in Mining Simulator, The Quarry, and etc.

If I’m not mistaken, if you were to “go out of bounds” in a mining game, you would notice that parts only load in depending on a part destroyed/missing for example:


https://gyazo.com/b55c8fc0750997a304136a412e6f9c51

Let’s say we destroyed the blue part in the middle by mining it, this in turn should check the surroundings for any parts from the top, bottom, and sides, though not corners of course. Let’s also say the blue part is found on the surface, since the top isn’t allowed as it is the limit, but the bottom is found to be empty, it will fill in the part with another random ore/block:


https://gyazo.com/9124910300fbcdbdb3ce12ef0aeeefec

This in turn creates a sort of “infinite” mining place that will keep generating random parts without having to do it all at once. You can also change the randomizer algorithim since it runs off of that.

Hopefully this gives you a premise of how they handle the system.

Yes, this is exactly how I understand it but to make it seems to be more advanced than it sounds, what would the math be involved used? I don’t touch modulus operations at all and though I am unsure, I feel like I might need it in this use case?

I think you would create a table of vectors that represents sides or use vector normalIds, but really I am unsure since I never seen mining game code.

You can probably raycast (seems crazy though :man_shrugging:) and check for parts that haven’t/have been mined, if a part isnt detected, it will add a part, if it is, then it adds a part. Or better yet, you can check the “vectors” by offsetting the position of the mined part to its surroundings by 4 studs or so, and check if a part exists there. Though fairly enough, raycasts are actually pretty inexpensive if used correctly :man_shrugging:.

Basically, if you want to add a part, offset the part that was mined by a a certain amount of specified studs to the other location.

He isn’t wanting entire scripts, only some tutorials. Also, C_Sharper I saw that tutorial some months ago and it isn’t very good.

Yes, as I do know the essence of how the mining system works as in that blocks generate based on the sides you don’t see after mining a block but I can’t figure out how I would code the math with it.

This is the idea:

1: The player destroys a block
2: create 6 blocks around it
3: If the camera sees the block destroy it

This can be the server script in ServerScriptService:

local BlocksFolder = --Put the location where your folder with the Blocks are
local ExampleBlock = -- Put a block that will be cloned when a block is destroyed
BlocksFolder.ChildRemoved:Connect(function(block)
	 local Player = block:WaitForChild("Destroyer").Value
	 if Player and game.Players:GetPlayerFromCharacter(Player) then
	 Player = game.Players:GetPlayerFromCharacter(Player)
     local StarterblockP = block.Position
     local block1 = ExampleBlock:Clone()
     block1.Position = Vector3.new(StarterblockP.X,StarterblockP.Y+block1.Size.Y,StarterblockP.Z)
     block1.Parent = BlocksFolder
     local block2 = ExampleBlock:Clone()
     block2.Position = Vector3.new(StarterblockP.X+block2.Size.X,StarterblockP.Y,StarterblockP.Z)
     block2.Parent = BlocksFolder
     local block3 = ExampleBlock:Clone()
     block3.Position = Vector3.new(StarterblockP.X,StarterblockP.Y-block3.Size.Y,StarterblockP.Z)
     block3.Parent = BlocksFolder
     local block4 = ExampleBlock:Clone()
     block4.Position = Vector3.new(StarterblockP.X-block4.Size.X,StarterblockP.Y,StarterblockP.Z)
     block4.Parent = BlocksFolder
     local block5 = ExampleBlock:Clone()
     block5.Position = Vector3.new(StarterblockP.X,StarterblockP.Y,StarterblockP.Z+block5.Size.Z)
     block5.Parent = BlocksFolder
     local block6 = ExampleBlock:Clone()
     block6.Position = Vector3.new(StarterblockP.X,StarterblockP.Y,StarterblockP.Z-block6.Size.Z)
     block6.Parent = BlocksFolder
     local S1 = game.ReplicatedStorage.PlayerSees:InvokeClient(Player,block1)
     local S2 = game.ReplicatedStorage.PlayerSees:InvokeClient(Player,block2)
     local S3 = game.ReplicatedStorage.PlayerSees:InvokeClient(Player,block3)
     local S4 = game.ReplicatedStorage.PlayerSees:InvokeClient(Player,block4)
     local S5 = game.ReplicatedStorage.PlayerSees:InvokeClient(Player,block5)
     local S6 = game.ReplicatedStorage.PlayerSees:InvokeClient(Player,block6)
     if S1 then
	     block1:Destroy()
     end
     if S2 then
	    block2:Destroy()
    end
     if S3 then
	     block1:Destroy()
     end
     if S4 then
	    block2:Destroy()
    end
     if S5 then
	     block1:Destroy()
     end
     if S6 then
	    block2:Destroy()
    end
    end
end)

this can be the script in PlayerGui:

local Camera = workspace.CurrentCamera

game.ReplicatedStorage.PlayerSees.OnClientInvoke = function(Block)
	local pos = Block.Position
	local _,CanSee = Camera:WorldToScreenPoint(pos)
	return CanSee
end

remember to put a Remote Function named PlayerSees inside ReplicatedStorage.
remember to put a ObjectValue with the name Destroyer in any block that can be destroyed.
remember when a player destroys a block set Destroyer’s Value to the player’s Character.

This may have bugs.

Note: I tested it and it works good.

I know how the tools would work and activate, also is invoking the client a good idea anyways?

I’m specifically talking about the chunk generation of the mining system by the way since it might be the part requiring some math I might not know or be good at.

Why math? I don’t think you need more math that + and - .

There isn’t any way to see if the camera can see a part. This is why I need Remote Functions and more conplicated stuff.

I’m pretty sure math would be needed and also I would be using CFrame multiplication to do the blocks’ placements.

You don’t need CFrame multiplication to place blocks, my script is doing that only with some + and some - . And math isn’t needed.

Hmm maybe you’re right, I’ll check it out when I get the chance.

1 Like

Thanks to @Kurookku he made a mining simulator like cave generation system. (Mining concept with cave generation - Roblox)

1 Like

@Dev_Ryan made an open source mining game which has basically everything you’d need

https://www.roblox.com/games/222446336/Open-Source-Mining-Game

1 Like

local _, withinScreenBounds = Camera:WorldToScreenPoint(part.Position)

I said that because isn’t any way that isn’t like what I put in the code.

However, I arleady put that. But, it isn’t working really well.