I really have no idea why isn’t it working, if someone has any ideas I would be grateful!
local DSS = game:GetService("DataStoreService")
local colorDS = DSS:GetDataStore("SaveCarColor")
local paint = script.Parent.Parent:WaitForChild("Body"):WaitForChild("Paint")
local part1 = paint:WaitForChild("Paint")
local spawned = false
local function loadColor(key)
print("loading...")
local Data = colorDS:GetAsync(key)
if Data then
for i, part in pairs(paint:GetChildren()) do
if part:IsA("MeshPart") then
part.Color.R = Data[1]
part.Color.G = Data[2]
part.Color.B = Data[3]
end
end
warn("car colors, loaded successfully!")
else
warn("no data")
end
end
local function saveWhenColorChange()
local ownerval = script.Parent.Parent:WaitForChild("Owner")
local plr = game:GetService("Players"):FindFirstChild(ownerval.Value)
if plr then
local key = plr.UserId.."-COLORCARSAVE"
script.Parent.Value = part1.Color
colorDS:SetAsync(key, {script.Parent.Value.R, script.Parent.Value.G, script.Parent.Value.B})
print("saved")
end
end
script.Parent.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
wait(1)
local ownerval = script.Parent.Parent:WaitForChild("Owner")
local plr = game:GetService("Players"):FindFirstChild(ownerval.Value)
local key = plr.UserId.."-COLORCARSAVE"
if script.Parent.Parent.Parent == game:GetService("Workspace") then
spawned = true
warn("spawned!")
loadColor(key)
end
end)
part1:GetPropertyChangedSignal("Color"):Connect(saveWhenColorChange)
The error it prints out: