-
What do you want to achieve? I want to save and load multiple values into a datastore!
-
What is the issue? If there are more than 4 values the others need a lot of time to load!
-
What solutions have you tried so far? I tried to look for solutions on the devforum but I didn’t find anything to help me
Here is the script:
-- local players = game:GetService("Players")
local dataStore = game:GetService("DataStoreService")
local CarDataStore1 = dataStore:GetDataStore("VehicleDataStore0")
players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "OwnedCars"
folder.Parent = player
local car1 = Instance.new("BoolValue")
car1.Name = "2020BloxWagenGulf"
car1.Parent = player.OwnedCars
car1.Value = CarDataStore1:GetAsync(player.UserId) or false
CarDataStore1:SetAsync(player.UserId, car1.Value)
local car2 = Instance.new("BoolValue")
car2.Name = "1983PIATDOS"
car2.Parent = player.OwnedCars
car2.Value = CarDataStore1:GetAsync(player.UserId) or false
CarDataStore1:SetAsync(player.UserId, car2.Value)
local car3 = Instance.new("BoolValue")
car3.Name = "2020TacoCarry"
car3.Parent = player.OwnedCars
car3.Value = CarDataStore1:GetAsync(player.UserId) or false
CarDataStore1:SetAsync(player.UserId, car3.Value)
local car4 = Instance.new("BoolValue")
car4.Name = "2015PiatHundred"
car4.Parent = player.OwnedCars
car4.Value = CarDataStore1:GetAsync(player.UserId) or false
CarDataStore1:SetAsync(player.UserId, car4.Value)
local car5 = Instance.new("BoolValue")
car5.Name = "2003JacuzziRS4"
car5.Parent = player.OwnedCars
car5.Value = CarDataStore1:GetAsync(player.UserId) or false
CarDataStore1:SetAsync(player.UserId, car5.Value)
local car6 = Instance.new("BoolValue")
car6.Name = "2020TokenModelIII(Uncustomizable)"
car6.Parent = player.OwnedCars
car6.Value = CarDataStore1:GetAsync(player.UserId) or false
CarDataStore1:SetAsync(player.UserId, car6.Value)
---
car1.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car1.Value)
car2.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car2.Value)
car3.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car3.Value)
car4.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car4.Value)
car5.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car5.Value)
car6.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car6.Value)
end)
end)
end)
end)
end)
end)
end)