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

Is it possible to data store stuff other than values?

I was just wondering if it was possible to data store other stuff other than values, e.g I might have a house building game where when a player places a part it gets put into a folder for that player, how would I save the contents of that folder and parent it to the player, so when the player leaves / joins it gets removed / added?

3 comments

0

you can only store values

0

k thanks

0

To store a part in a datastore, you can store the properties of the part the player places and then create a new one with the same properties when the player rejoins

1 answer

This should probably work, I have not tested it cause I do thing anything I do is good. Here though is a good idea

local DataStore = game:GetService("DataStoreService")
local HS = DataStore:GetDataStore("HouseSaving")

game.Players.PlayerAdded:connect(function(player)
	local leader = Instance.new("Folder", player)
	leader.Name = "PlayerSaves"
	
	local Houses = Instance.new("Folder", leader)
	Houses.Name = "HouseSaves"
	
	HS:SetAsync(player.UserId, Houses)
	
	Houses.Changed:connect(function()
		print("SavingData")
		HS:SetAsync(player.UserId, Houses)
	end)
	
end)

game.Players.PlayerRemoving:connect(function(player)
	HS:setAsync(player.UserId, player.PlayerSaves.Houses)
end)

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