I have a inventory system that gives the players the tools whenever a new bool value is created inside a folder inside player, but how do i save the bool values, im not familiar with data store and those things, how would i do it?

local dataStoreService = game:GetService("DataStoreService")
local dataStore = dataStoreService:GetDataStore("ItemsDataStore")
local replicatedStorage = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(p)
	
	local inv = Instance.new("Folder")
	inv.Name = "Inventory"
	inv.Parent = p
	
	-- give the tools everytime the character is added
	p.CharacterAdded:Connect(function(c)
		for i, tool in pairs(inv:GetChildren()) do
			if tool:IsA("BoolValue") then
				if game.ReplicatedStorage.Things:FindFirstChild(tool.Name) then
					if p.Backpack:FindFirstChild(tool.Name) == nil then
						local tooltogive = game.ReplicatedStorage.Things:FindFirstChild(tool.Name):Clone()
						tooltogive.Parent = p.Backpack
					end
				end
			end
		end
	end)
end)

3 comments

0

You could use SetAsync() to save values.. Or you could use UpdateAsync() to update an existing value inside the data store

0

But what do i put in there

0

Answer me