Hello. I am making a datasave which saves two (or more) bool values in the player in CarStats. I have two datasave scripts in the game one for money and one for cars (this one). It does not work and i need some help. I try it online in a roblox server and on solo but it still does not work. CarDataSave Script:
local dataStoreService = game:GetService("DataStoreService"):GetDataStore("Earth2DataStore") game.Players.PlayerAdded:connect(function(plr) local key = 'id-'..plr.userId local stats = Instance.new('IntValue',plr) stats.Name = "CarStats" local CamaroOwned = Instance.new('BoolValue',stats) CamaroOwned.Name = "CamaroSSOwned" local LamOwned = Instance.new('BoolValue',stats) LamOwned.Name = "LamborghiniOwned" local getSavedData = dataStoreService:GetAsync(key) if getSavedData then CamaroOwned.Value = getSavedData[1] LamOwned.Value = getSavedData[2] else local saving = {CamaroOwned.Value, LamOwned.Value} dataStoreService:SetAsync(key,saving) end end) game.Players.PlayerRemoving:connect(function(plr) local key = 'id-'..plr.userId local save = {plr.CarStats.CamaroSSOwned.Value, plr.CarStats.LamborghiniOwned.Value} dataStoreService:SetAsync(key,save) end)
As you can see it saves two bool values in the player so it knows if the player owns the car. I really need help with this i have been trying to do this for months now. Remember i have tried it in a server! Please help!
try making the names for CamaroOwner.Name = CamaroOwned. See if that does anything. Also why is there stats, you don't need that. Just put the owned car boolvalues under plr."
Also, make sure your other scripts that spawn the car turn the value to true. Doing it manually didn't work for me. Make sure the other script does it!
Try going in the "Create" Tab and then going to your game and clicking the setting and then "Configure this game" then turn on API Access