Any fix to booleans not spawning in folder?
Asked by
2 years ago Edited 2 years ago
local players = game:GetService("Players")
local dataStore = game:GetService("DataStoreService")
local CarDataStore1 = dataStore:GetDataStore("DealerV1")
players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "OwnedCars"
folder.Parent = player
local car1 = Instance.new("BoolValue")
car1.Name = "Crownvick"
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 = "Gwagon"
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 = "Hellcat"
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 = "Tahoe"
car4.Parent = player.OwnedCars
car4.Value = CarDataStore1:GetAsync(player.UserId) or false
CarDataStore1:SetAsync(player.UserId, car4.Value)
---
car1.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car1.Value)
end)
car2.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car2.Value)
end)
car3.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car3.Value)
end)
car4.Changed:Connect(function()
CarDataStore1:SetAsync(player.UserId, car4.Value)
end)
end)