Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can Someone Help with DataStore Script?

I'm trying to make a script that uses a script that saves the player's inventory if they leave the game. Here's what I have so far:

local ds = game:GetService("DataStoreService"):GetDataStore("tools")

game.Players.PlayerAdded:connect(function(player)
	local key = "user_" .. player.userId
	ds:UpdateAsync(key, function(old)
		old = game.Players.LocalPlayer.Backpack:GetChildren()
		if old:IsA("Tool") then
		local new = old or nil
		local tool = old:Clone()
		tool.Parent = game.Players.LocalPlayer.Backpack
		return new
		end
	end)
	
end)

I copied some of it from the wikia. I think I'm doing it all wrong. Please help!

1 comment

0

You cannot save instances with datastore you can only save values and tables, those sort of things.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.