Persistent Player Equipment (Storage)


-- Contributed by: FearTheDev(John) from (user @) CoreGames.com

local EQUIPMENT = script.parent

function OnEquipped(equipment)
    local playerData = Storage.GetPlayerData(equipment.owner)

    if type(playerData.equipment) ~= "table" then
        playerData.equipment = {}
    end

    print("Persisently equipping "..equipment.name.." to player.")

    table.insert(playerData.equipment, equipment.sourceTemplateId)
end

EQUIPMENT.equippedEvent:Connect(OnEquipped)

Latest Posts