I have a script that saves stats between places, but I'm newer to scripting and don't know how I'd go about doing the same with items in your inventory, including items that aren't in the starter pack. Here's the script I'm working with (not mine)

	--[[Savin'
	        Dem
	            Stats  
	--]]
	game.Players.PlayerRemoving:connect(function(player)
	    local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
	 
	local statstorage = player:FindFirstChild("leaderstats"):GetChildren()
	for i =  1, #statstorage do
	    datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
	    print("saved data number "..i)
	 
	end
	print("Stats successfully saved")  
	end)
	 
	 
	--[[
	    Loadin'
	        Dem
	            Stats
	--]]
	game.Players.PlayerAdded:connect(function(player)
	        local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
	 
	    player:WaitForChild("leaderstats")
	    wait(1)
	    local stats = player:FindFirstChild("leaderstats"):GetChildren()
	    for i = 1, #stats do           
	    stats[i].Value = datastore:GetAsync(stats[i].Name)
	    print("stat numba "..i.." has been found")
	        end
end)

2 comments

0

TeleportService

0

could you elaborate on that? Idrk what I'm doing too well