I’ve created this datatstore that saves data stored in the player but it never says it has successfully saved and it also never loads the data even though it says its successfully loaded? I’m guessing the data does not exist?
--[Varibles]--
local datastoreService = game:GetService("DataStoreService")
local playerData = datastoreService:GetDataStore("playerData")
local inventory = datastoreService:GetDataStore("playerData")
--[Datastore & Leaderstats]--
game.Players.PlayerAdded:Connect(function(player)
local dataFolder = Instance.new("Folder", player)
dataFolder.Name = "Data"
local mainFolder = Instance.new("Folder", dataFolder)
mainFolder.Name = "Main"
local rankVarible = Instance.new("StringValue", mainFolder)
rankVarible.Name = "Rank"
local equiptWeaponVarible = Instance.new("StringValue", mainFolder)
equiptWeaponVarible.Name = "EquiptWeapon"
local equiptAccessoryVarible1 = Instance.new("StringValue", mainFolder)
equiptAccessoryVarible1.Name = "EquiptAccessory1"
local equiptAccessoryVarible2 = Instance.new("StringValue", mainFolder)
equiptAccessoryVarible2.Name = "EquiptAccessory2"
local equiptArmorVarible1 = Instance.new("StringValue", mainFolder)
equiptArmorVarible1.Name = "EquiptArmor1"
local equiptArmorVarible2 = Instance.new("StringValue", mainFolder)
equiptArmorVarible2.Name = "EquiptArmor2"
local equiptAbilityVarible1 = Instance.new("StringValue", mainFolder)
equiptAbilityVarible1.Name = "EquiptAbility1"
local equiptAbilityVarible2 = Instance.new("StringValue", mainFolder)
equiptAbilityVarible2.Name = "EquiptAbility2"
local equiptAbilityVarible3 = Instance.new("StringValue", mainFolder)
equiptAbilityVarible3.Name = "EquiptAbility3"
local equiptAbilityVarible4 = Instance.new("StringValue", mainFolder)
equiptAbilityVarible4.Name = "EquiptAbility4"
local equiptAbilityVarible5 = Instance.new("StringValue", mainFolder)
equiptAbilityVarible5.Name = "EquiptAbility5"
local equiptAbilityVarible6 = Instance.new("StringValue", mainFolder)
equiptAbilityVarible6.Name = "EquiptAbility6"
local data = playerData:GetAsync(player.UserId)
if data then
rankVarible.Value = data.rankVarible
equiptWeaponVarible.Value = data.equiptWeaponVarible
equiptAccessoryVarible1.Value = data.equiptAccessoryVarible1
equiptAccessoryVarible2.Value = data.equiptAccessoryVarible2
equiptArmorVarible1.Value = data.equiptArmorVarible1
equiptArmorVarible2.Value = data.equiptArmorVarible2
equiptAbilityVarible1.Value = data.equiptAbilityVarible1
equiptAbilityVarible2.Value = data.equiptAbilityVarible2
equiptAbilityVarible3.Value = data.equiptAbilityVarible3
equiptAbilityVarible4.Value = data.equiptAbilityVarible4
equiptAbilityVarible5.Value = data.equiptAbilityVarible5
equiptAbilityVarible6.Value = data.equiptAbilityVarible6
else
rankVarible.Value = "F-"
end
print("Sucessfully loaded:".. " ".. player.Name.. "s".. " Data.")
end)
game.Players.PlayerRemoving:Connect(function(player)
local data = {
rankVarible = player.Data.Main.Rank.Value,
equiptWeaponVarible = player.Data.Main.EquiptWeapon.Value,
equiptAccessoryVarible1 = player.Data.Main.EquiptAccessory1.Value,
equiptAccessoryVarible2 = player.Data.Main.EquiptAccessory2.Value,
equiptArmorVarible1 = player.Data.Main.EquiptArmor1.Value,
equiptArmorVarible2 = player.Data.Main.EquiptArmor2.Value,
equiptAbilityVarible1 = player.Data.Main.EquiptAbility1.Value,
equiptAbilityVarible2 = player.Data.Main.EquiptAbility2.Value,
equiptAbilityVarible3 = player.Data.Main.EquiptAbility3.Value,
equiptAbilityVarible4 = player.Data.Main.EquiptAbility4.Value,
equiptAbilityVarible5 = player.Data.Main.EquiptAbility5.Value,
equiptAbilityVarible6 = player.Data.Main.EquiptAbility6.Value,
}
playerData:SetAsync(player.UserId, data)
print("Sucessfully saved:".. " ".. player.Name.. "s".. " Data.")
end)
Any reason why it won’t save or won’t load the data?