Basically, I’m making a murder game and i’m trying to figure out how to make an inventory but i’m really dumb so can someone guide me through how I would use DataStore to do it? i’ve been researching but I still can’t figure it out
The knife and gun skins would be stored in ReplicatedStorage
Just use a table to store which skins the player has, then save it. Look here for more information on how to save data.
local inventory = {}
inventory.skins = {}
local function awardSkin(skin)
inventory.skins[skin] = true --skin is added
end
1 Like
The overall “method” of inventories is very simple. What you want to do with that, though, is what can be complicated (like how you use what is stored in your inventory or whatever).
The “inventory” can be stored in a folder within a player, and will be permanently stored in a datastore. DataStore only used when player joins/leaves.
local PlayerData = game:GetService("DataStoreService"):GetDataStore("PlayerData")
local Players = game:GetSerivce("Players")
Players.PlayerAdded:Connect(function(plr)
--[[Create your folder here and insert values or whatever which you gt from the
player's stored data via. PlayerData:GetAsync(key)]]
end)
Players.PlayerRemoving:Connect(function(plr)
--[[
Set your player's data with PlayerData:SetAsync(key, inventory)
]]
end)
This is, of course, not a tutorial on datastores and whatnot. This is the outline of how you can access an inventory which saves via datastores.
MY BRAIN HURTSSSSSSSSSSSSS owie :c