Why is this error happing?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! I want to know why this error is happing.

  2. What is the issue? The code errors for some reason: Argument 3 missing or nil

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I don’t know

I just want to get this error resolved asap!

local UMS = game:GetService("MemoryStoreService")
local map = UMS:GetSortedMap("ServersBrowser")

function PlaceBid(itemKey, bidAmount)
	map:UpdateAsync(itemKey, function (item)
		item = item or { highestBid = 0 }
		if item.highestBid < bidAmount then
			item.highestBid = bidAmount
			return item
		end
		return nil
	end)
end

PlaceBid(1, 5000)

Pls specify the line in which it errors.

1 Like

Line 5 in function PlaceBid. I think

MemoryStoreSortedMap:UpdateAsync(string key , Function transformFunction , int64 expiration)

The third argument/parameter for the method you are using determines the expiration date for the specific key which are in seconds.

local UMS = game:GetService("MemoryStoreService")
local map = UMS:GetSortedMap("ServersBrowser")

function PlaceBid(itemKey, bidAmount)
	map:UpdateAsync(itemKey, function (item)
		item = item or { highestBid = 0 }
		if item.highestBid < bidAmount then
			item.highestBid = bidAmount
			return item
		end
		return nil
	end, 100) --> For instance, the data we updated would expire after 100 seconds unless we update it once again. You can modify the number, but it must be an integer
end

PlaceBid(1, 5000)
2 Likes