so i tried to make a simple script that literally just saves a brick color. heres the not working script:

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("DS1")
game.Players.PlayerAdded:Connect(function(plr)
	local part= game.Workspace.Part
	local success,err = pcall(function()
		part.BrickColor = ds1:GetAsync(plr.UserId)
	end)
	if success then
		print("Your Data Has Been Loaded.")
	else
		print("Your Data Loading Has Failed.")
		warn(err)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local part= game.Workspace.Part
	local success,err = pcall(function()
		ds1:SetAsync(plr.UserId, part.BrickColor)
	end)
	if success then
		print("Your Data Has Been Saved.")
	else
		print("We Got An Error While Saving Your Data.")
		warn(err)
	end
end)

i would appreciate any help.

4 comments

0

Better use color3. Cuz that really easier

0

Have you tried storing the BrickColor as a string, and then reconstructing the BrickColor from the string? I think this documentation (https://developer.roblox.com/en-us/api-reference/datatype/BrickColor) can help you store the color as a string, then reconstruct it as a BrickColor when you need to do so.

0

Yeah ^^ you can

0

only save numbers, strings or tables to datastore