Hello everyone, I have a problem with creating an Marketplace where people can sell the skins from my game. And, I don’t know how to make it properly so everyone can see list of all sells.
By the way, for the main stats I’ve used Profile Service!
So, firstly, I tried used OrderedDataStore… BUT, I was having a lot of problem.
I’ve made it like this:
local function setSellData(player: Player, username: string?, skinKey: array<>?, gamepassId: number<>?)
local data = {
username = username or "",
skin = skinKey and skinKey.key or "",
guid = skinKey and skinKey.id or "",
gamepass = gamepassId or 0,
time = os.time()
}
local success, result = pcall(function()
local strId = tostring(player.UserId)
local dataString, score = HttpService:JSONEncode(data), data.time
MarketplaceStore:SetAsync(strId, score)
PlayerDataStore:SetAsync(strId, dataString)
end)
if success then
print("Data stored successfully for player: " .. player.Name)
print("Stored Data: ", data)
else
warn("Failed to store data for player: " .. player.Name)
end
end
local function updateMarketplace(player: Player)
local success, pages = pcall(function()
return MarketplaceStore:GetSortedAsync(false, 100)
end)
if success then
local data = {}
local top = pages:GetCurrentPage()
for _, v in ipairs(top) do
local playerId, score = v.key, v.value
local success, dataString = pcall(function()
return PlayerDataStore:GetAsync(playerId)
end)
if success and dataString then
local dataTable = HttpService:JSONDecode(dataString)
print("Retrieved Data for player: ", dataTable)
table.insert(data, dataTable)
MarketplaceStore:SetAsync(playerId, dataTable)
else
print("Failed to retrieve data for player: " .. playerId)
end
end
print(data)
Signals.Functions.Marketplace["Set"]:InvokeClient(player, data)
return data
else
print("Failed to get sorted data: " .. tostring(pages))
end
end
while task.wait(60) do
for _, player in pairs(game.Players:GetPlayers()) do
if player.UserId > 0 then
local success, dataString = pcall(function()
return MarketplaceStore:GetAsync(tostring(player.UserId))
end)
if success and dataString then
print("Updating Data for player: " .. player.Name)
if dataString then
local dataTable = HttpService:JSONDecode(dataString)
pcall(function()
MarketplaceStore:UpdateAsync(tostring(player.UserId), function(oldVal)
return HttpService:JSONEncode(dataTable)
end)
end)
end
else
print("Failed to retrieve data for player: " .. player.Name)
end
end
end
end
So, I was having problem like, ValueNotAllowed, you can’t see listing, etc.
I’ve already tried encoding and decoding, and it still doesn’t work.
A LOT of problem. And, I don’t know if I should try make it with GlobalDataStore…
But if someone can help me, it would be really appreciated!