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

how would i save colours for multiple parts and multiple houses?

i want to save colours for multiple houses and each house has multiple houses how would i save them? i know how to save them the long way so like

--when player leaves--
local colourdatastore =game:GetService("DataStoreService"):GetDataStore("Colour")
colourdatastore:SetAsync(player.UserId..":wallcolour:")

--when player enters--
local getwallcolour= colourdatastore:GetAsync(player.userId..":WallColour")
if wallcolour == nil then
	wallcolour.Value = Brickcolor.new("Black")
else
	wallcolour.Value = getwallcolour
end

iis there a easier way to save them? because the way i know will take a long time and alot of space, anything will be great TY.

5 comments

0

Use a table to store them.

0

yes i can use a table but its for multiple houes and each house can have multiple colours

0

how would i access it from a table tho? it comes out nil when i do v.Value

0

I dont understand your point, using a table would still be much more efficient. You could save every house and every color into one table, and only require 1 data store.

0

Hmm, let me see if i can whip something up. Hopefully its what you mean.

1 answer

✓ Accepted answer

Hopefully this is more or less what you were looking for, the way I structured it you'd either have to make the strings here or child them in a folder and clone them into the player.

local colourdatastore =game:GetService("DataStoreService"):GetDataStore("Colour")

function savefiles(player)
    local SaveTable = {
        wallcolor1 = player.House1.wallcolor1.Value,
        wallcolor2 = player.House1.wallcolor2.Value,
        wallcolor3 = player.House1.wallcolor3.Value,
        wallcolor4 = player.House1.wallcolor4.Value
    }
    return SaveTable
end
local save = savefiles(player)

local H1 = player.House1
local saved = colourdatastore:GetAsync(player.userId)

game.Players.PlayerAdded:Connect(function(player)--load players info
	function loadsave(player, save)
		H1.wallcolor1.Value = saved.wallcolor1
		H1.wallcolor2.Value = saved.wallcolor2
		H1.wallcolor3.Value = saved.wallcolor3
		H1.wallcolor4.Value = saved.wallcolor4
	end
	function pullthedata()
		--this is where you'll need to make something to grab the color values from the strings and convert the brick color into corresponding color
	end
end)

function savefunc(player)
	colourdatastore:SetAsync(player.userId,save)
end

game.Players.PlayerRemoving:Connect(savefunc)--save players info on d/c

1 comment

0

Thanks bro.

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