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

Saving Limited items in datastores?

Asked by 6 years ago

So I'm trying to create an automated system to handle updating values across all servers for items with limited numbers. Right now I have it set w/ a custom key and the values are created and put in replicatedstorage. Everything I'm doing right now is just for testing purposes until I figure out how exactly I want to handle where everything is and how to handle them.

The idea is that certain roles/abilities/tools are limited to a certain number of players. Now my question is: Is this doable and if so should I do it or should I try another method?

My code right now is as following:

01local DataStore = game:GetService("DataStoreService"):GetDataStore("ServerSavesTest1")
02 
03print("Creating Stats...") --All prints are to show where the script is and when any problems occur.
04 
05local Roles = Instance.new("Folder") --Folder to hold a few items that I want limited.
06Roles.Name = "PlayerRoles"
07Roles.Parent = game.ReplicatedStorage
08 
09local ltd1= Instance.new("NumberValue") --First item to be limited, only doing 3 to test.
10ltd1.Name = "GiantFireball"
11ltd1.Value = 0 --This will be a userid of the player who retrieves this power. Limited to one player at a time, I plan to check when the user who has this joins the game and give them it.
12ltd1.Parent = Roles
13 
14local ltd2 = Instance.new("NumberValue")
15ltd2.Name = "GiantWaterWave"
View all 56 lines...
0
So like a live update awesomeipod 607 — 6y
0
Yeah, sorry for late replies. I end up asking questions then forget to check them. I figured out a solution. OneTruePain 191 — 6y

1 answer

Log in to vote
2
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

Yesterday I was able to create a custom server shutdown message by using a hacky method (doesn't involve data stores).

I uploaded a asset to ROBLOX: https://www.roblox.com/library/2355087160/SM-UPDATE The description has important information: the updated version of the asset and the shutdown message.

With MarketplaceService, you can get the asset's description by using GetProductInfo():

01local MarketplaceService = game:GetService("MarketplaceService")
02 
03local CurrentVersion = "v1.0"
04 
05local AssetID = 2355087160
06local AssetInfo = MarketplaceService:GetProductInfo(AssetID, Enum.InfoType.Asset) -- GetProductInfo() has two parameters, the asset's id and the type
07local Description = AssetInfo.Description -- this returns as string
08 
09--I use a loop to check if the description (updatedVersion) version matches with the CurrentVersion:
10while true do
11    Description = AssetInfo.Description
12    local updatedVersion = string.sub(Description, 1, 4) -- gets the first 4 string from the description
13    if updatedVersion ~= CurrentVersion then
14        --kick players
15    end
16    wait(5);
17end

The script basically checks if the version matches the description version and if not kicks all players.

I suggest to upload a asset to ROBLOX that contains the updated vaues and use the description version I used above. If the versions don't match, load the asset in with InsertService, get the new values and replace the old ones with those.

0
Not quite what I meant, but I gave it a try for something else and it helped. Thanks! OneTruePain 191 — 6y
Ad

Answer this question