I wanted to ask you guys if there was a easier way to approach rather than having to create and datastore a whole new IntValue that would hold this information.
You could use one string value, to handle all of this; it’s a bit hacky, bit would work IMO.
local String = "Cake 1, CakeE 2, CakeF 3"
local TempTable = {}
local Result = {}
function csvToTable(List)
for Line in String:gmatch("[^,]+") do
TempTable[1+#TempTable] = Line
print(Line)
end
print(TempTable)
for _,Line in ipairs(TempTable) do
local Index, Value = Line:match("(.*) (%d+)")
print(Index)
print(Value)
Result[Index] = Value
end
end
while true do
wait(5)
csvToTable(String)
print(Result)
end
Here you effectively have a string Cake 1, CakeE 2, CakeF 3
The code will convert that into a table where the Cake name is the index, and the number is the value.
It’s one way you could do this avoiding a million intvalues.
just use smth like astral did with the string although i think its just better to have a folder with a ton of values and just make some for loop to save them into data stores and also for changing these values u can make another for loop that will make a connection for every value in that folder
i dunno i have about 100 int values in my game per player and it works fine, for data saving just do smth like this:
local DataStorage = DataService:GetDataStore("Values")
Players.PlayerAdded:Connect(function(player)
local Values = game.ServerStorage.Values:Clone() --Folder with ur values
Values.Parent = player
local data
local success, errormessage = pcall(function()
data = DataStore:GetAsync(player.UserId.."-Values") --Gets that we saved
end)
if success and data then
for i,v in pairs(Values:GetChildren()) do
Values:FindFirstChild(i).Value = v --if it finds the data then to all values in a folder it gives a value bruh
end
else
end)
Players.PlayerRemoving:Connect(function(Player)
local DataToSave = {}
for i,v in pairs(Player.Values:GetChildren())
DataToSave[v.Name] = v.Value --saves stuff idk
DataStore:SetAsync(player.UserId.."-Values", DataToSave)
end)
btw that rily raw code written in 5 min so yeah hope u get how that supposted to wokr
and what do you mean by “As well as if I want stats for each value I need to double it so it calculates how much a player has sold of each.” just each time player sells smth you find that smth in a folder and add a quanity of sold stuff to it
alr i will have a dinner rn
alr i had it so maybe you add me friends on roblox that just would be more practical than write to each other each like 12hrs uknow
[quote=“101010lilfanerka, post:13, topic:1753549”]
ch time player sells smth you find that smth in a folder and add a quanity of sold stuff to it
[/quote] well so as i understand each time a player sells smth in ur game you want to detect it and make a value go bigger right? So just make a connection that can do just that idk dud
There is a value called Paper in a game. In that game people buy paper. And sell paper. When people sell paper I want that to add all together to create a new value which would be sold paper.
My question is instead of making 2 leaderstat values one for regular paper and one for sold paper.