I have this script:
local ds = game:GetService("DataStoreService"):GetDataStore("carsave")
game.Players.PlayerAdded:Connect(function(player)
local data = Instance.new("Folder", player)
data.Name = "cars"
local corvan = Instance.new("IntValue", data)
corvan.Name = "oldvan"
local corvancolor = Instance.new("Color3Value", data)
corvancolor.Name = "oldvancolor"
local vans = Instance.new("IntValue", data)
vans.Name = "van"
local vancolor = Instance.new("Color3Value", data)
vancolor.Name = "vancolor"
local sedan = Instance.new("IntValue", data)
sedan.Name = "sedan"
local sedancolor = Instance.new("Color3Value", data)
sedancolor.Name = "sedancolor"
local musclecar = Instance.new("IntValue", data)
musclecar.Name = "musclecar"
local musclecarcolor = Instance.new("Color3Value", data)
musclecarcolor.Name = "musclecarcolor"
local suv = Instance.new("IntValue", data)
suv.Name = "suv"
local suvcolor = Instance.new("Color3Value", data)
suvcolor.Name = "suvcolor"
local sportscar = Instance.new("IntValue", data)
sportscar.Name = "sportscar"
local sportscarcolor = Instance.new("Color3Value", data)
sportscarcolor.Name = "sportscarcolor"
local supercar = Instance.new("IntValue", data)
supercar.Name = "supercar"
local supercarcolor = Instance.new("Color3Value", data)
supercarcolor.Name = "supercarcolor"
local truck = Instance.new("IntValue", data)
truck.Name = "truck"
local truckcolor = Instance.new("Color3Value", data)
truckcolor.Name = "truckcolor"
local lightutilityvehicle = Instance.new("IntValue", data)
lightutilityvehicle.Name = "lightutilityvehicle"
local lightutilityvehiclecolor = Instance.new("Color3Value", data)
lightutilityvehiclecolor.Name = "lightutilityvehiclecolor"
local dunebuggy = Instance.new("IntValue", data)
dunebuggy.Name = "dunebuggy"
local dunebuggycolor = Instance.new("Color3Value", data)
dunebuggycolor.Name = "dunebuggycolor"
local stats = ds:GetAsync(player.UserId)
if stats ~= nil then
corvan.Value = stats[1]
vans.Value = stats[3]
sedan.Value = stats[5]
musclecar.Value = stats[7]
suv.Value = stats[9]
sportscar.Value = stats[11]
supercar.Value = stats[13]
truck.Value = stats[15]
lightutilityvehicle.Value = stats[17]
dunebuggy.Value = stats[19]
corvancolor.Value = stats[2]
vancolor.Value = stats[4]
sedancolor.Value = stats[6]
musclecarcolor.Value = stats[8]
suvcolor.Value = stats[10]
sportscarcolor.Value = stats[12]
truckcolor.Value = stats[14]
lightutilityvehiclecolor.Value = stats[16]
dunebuggycolor.Value = stats[18]
supercarcolor.Value = stats[20]
else
corvan.Value = 0
vans.Value = 0
sedan.Value = 0
musclecar.Value = 0
suv.Value = 0
sportscar.Value = 0
truck.Value = 0
lightutilityvehicle.Value = 0
dunebuggy.Value = 0
corvancolor.Value = BrickColor.new("White")
vancolor.Value = BrickColor.new("White")
sedancolor.Value = BrickColor.new("White")
musclecarcolor.Value = BrickColor.new("White")
suvcolor.Value = BrickColor.new("White")
sportscarcolor.Value = BrickColor.new("White")
truckcolor.Value = BrickColor.new("White")
lightutilityvehiclecolor.Value = BrickColor.new("White")
dunebuggycolor.Value = BrickColor.new("White")
supercarcolor.Value = BrickColor.new("White")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local save = {}
table.insert(save, player.cars.oldvan.Value)
table.insert(save, player.cars.van.Value)
table.insert(save, player.cars.sedan.Value)
table.insert(save, player.cars.suv.Value)
table.insert(save, player.cars.sportscar.Value)
table.insert(save, player.cars.truck.Value)
table.insert(save, player.cars.lightutilityvehicle.Value)
table.insert(save, player.cars.dunebuggy.Value)
table.insert(save, player.cars.oldvancolor.Value)
table.insert(save, player.cars.vancolor.Value)
table.insert(save, player.cars.sedancolor.Value)
table.insert(save, player.cars.suvcolor.Value)
table.insert(save, player.cars.sportscarcolor.Value)
table.insert(save, player.cars.truckcolor.Value)
table.insert(save, player.cars.lightutilityvehiclecolor.Value)
table.insert(save, player.cars.dunebuggycolor.Value)
ds:SetAsync(player.UserId, save)
end)
What I want the script to do is save color3 so that when the player enters the game again, after leaving, the car would for example be blue. I get two errors:
invalid argument #3 (Color3 expected, got number)
This is for line 81, which is:
corvancolor.Value = stats[2]
Also an error at the last line:
Cannot store Array in data store. Data stores can only accept valid UTF-8 characters.