PlayerAdded (NonGlobal)

CacheTable:PlayerAdded(CallbackFunction)

This is only usable within the server.

This function sets a callback for when a player is added to the cache/game. This only works for NonGlobal (Global property not set to true)

If DatastoreSave property is set to true the callback function will only be called after the data is loaded.

PlayerAdded Arguments:

Callback function (a function that is called whenever a player is added (player joined) to the cache| Given arguments is NewCache)

Example Usage:

local InventoryCache = Cache:Create("Inventory", 
	{DatastoreSave = true, Replicate = true}, 

	{
		["Available Slots"] = 10,
		["MainSword"] = {Item = "Sword",Level = 1, XP = 1},
		{Item = "Apple"},
	}
)


InventoryCache:PlayerAdded(function(player, NewCache) 
	task.wait(5)
	InventoryCache:Update(player, function(CurrentCache)

		OldCache.MainSword.Level = 25


		return OldCache

	end)
end)