Skip to main content

AddElement

Adds an object into an array. Will fail if you attempt to use it an a non-array value.

Parameters:

NameTypeDescription
playerplayerThe player whose data we want to access
pathstringThe path to the user data
elementanyThe element that we want to add into the players array

Returns:

NameTypeDescription
void

Example:

local ServerScriptService = game:GetService("ServerScriptService")
local ProStore3 = require(ServerScriptService.ProStore3)

ProStore3.PlayerJoined:Connect(function(player : Player)
print(ProStore3.Get(player, "Inventory"))
ProStore3.AddElement(player, "Inventory", {id = "sword", damage = 2})
print(ProStore3.Get(player, "Inventory"))
ProStore3.AddElement(player, "Inventory", {id = "knife", damage = 3})
print(ProStore3.Get(player, "Inventory"))
end)