Making a mining system

So far, I’ve made a tool that can detect if it’s in a radius of any breakable object and request a break without being able to be exploited. The only thing I don’t know how to achieve, is if I want to have mining tools with different stats. If the information is stored in the tool when it is given to the player by the server the player can change values and scripts to make the mining tool more powerful. I also don’t want the mining tool to be able to cloned. This would dupe an item and ruin my game’s economy.

How should I go about making a system like this without holes in it that can dupe tools or change their powers?

3 Likes

This is in tthe wrong category, put it in #help-and-feedback:scripting-support

I’m not asking how to script it. I’m asking about how I would design a system like this.

For one, to prevent people from duping your item, keep it secured in ServerStorage, and always parent it from the server.

As for item data, what I do is keep a module inside each tool, something like ‘Settings’ and that will contain all the necessary data for each tool (speed, blocks it can break, etc.) and then use that. Not entirely sure how exploitable that system is, but it’s worked well for me in the past

My tools is being held by the player. Duping the tool would be the client copying and pasting it again into their backpack.

This seems like a good idea. The only problem is cheaters can modify any scripts on the client like this module script containing important data that shouldn’t change. At the cost of lag time would it be a better idea for the server to track what item the player is holding and know all the data about it rather than the client keeping that information?

I don’t really think that’s worth it. I know that most mining games on Roblox would use something like Values inside the tools.

Or what could work is have their data stored in a module inside repstorage. Use the client to view the data from repstorage to do client stuff, then from the server, require the same module and so sanity checks from what the client is telling the server to make sure the numbers match up.

1 Like

I see, but how would the module script update values about what the client has?

Something like this. I don’t know what stats you have, etc. But basically the client would grab the section of code their pickaxe is (so if they have Classic Pickaxe then it’d grab its data) When you mine or whatever, it’d go to the server, the server would check what pick they have (from the server) and compare the data the client has sent to the server, with the data the server has.

return {
    ['Classic Pickaxe'] = {Speed = 1, Blocks = {'Dirt', 'Stone', 'Iron'},
    ['Iron Pickaxe'] = {Speed = 1.25, Blocks = {'Dirt', 'Stone', 'Iron', 'Gold'},
    -- etc...
}

Basically if a player has a classic pickaxe and on the client they try using the iron pickaxe data, when it goes to the server, the server can see that the player is using a classic pickaxe and not an iron one, thus the data wouldn’t match up.

3 Likes

So the client sends a message to the server containing mining data along with what the pickaxe that the client thinks it has and the server, before processing the mining checks to see if this pickaxe that the client reported it was using (with and id or whatever), makes sure that they have this pickaxe equipped in their character model along with having it in their inventory?

1 Like

Yes exactly! :smiley: As long as the server is doing sanity checks to make sure the client isn’t sending it false data you should be good :+1:

3 Likes