My datastore is not loading, I have checked the security options and all are enabled. I can’t seem to solve this issue.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("COKECOUNTYDSSERVICE")
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local stats = Instance.new("Folder",player)
stats.Name = "leaderstats"
local datav1 = Instance.new("Folder",player)
datav1.Name = "DataV1"
local Cash = Instance.new("NumberValue",stats)
Cash.Name = "Cash"
Cash.Value = 400
local FOID = Instance.new("BoolValue",datav1)
FOID.Name = "FOID"
FOID.Value = false
local data
local data2
local success,MSG = pcall(function()
data = DataStore:GetAsync(player.UserId.."-CFOID")
data2 = DataStore:GetAsync(player.UserId.."-CCash")
end)
if success then
FOID.Value = data
Cash.Value = data2
else
FOID.Value = false
Cash.Value = 400
end
end
local function OnPlayerRemoving(player)
local success,MSG = pcall(function()
DataStore:SetAsync(player.UserId.."-CFOID",player.DataV1.FOID.Value)
DataStore:GetAsync(player.UserId.."-CCash",player.leaderstats.Cash.Value)
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(OnPlayerRemoving)