My Data Store will not save load a single thing. I do not know what I did wrong. There's nothing in the output. Here is my script:
local dataStoreService = game:GetService("DataStoreService")
local dataStore1 = dataStoreService:GetDataStore("Coins")
local dataStore2 = dataStoreService:GetDataStore("Level")
local dataStore4 = dataStoreService:GetDataStore("EXP")
game.Players.PlayerAdded:Connect(function(player)
local data = Instance.new("Folder",player)
data.Name = "Data"
local level = Instance.new("IntValue",data)
level.Name = "Level"
level.Value = 1
local coins = Instance.new("IntValue",data)
coins.Name = "Coins"
coins.Value = 0
local exp = Instance.new("IntValue", level)
exp.Name = "Exp"
exp.Value = 0
local maxExp = Instance.new("IntValue", level)
maxExp.Name = "Max"
local afk = Instance.new("BoolValue",player)
afk.Name = "afk"
afk.Value = false
while wait(1) do
maxExp.Value = 1000 + player["Data"].Level.Value
if exp.Value >= maxExp.Value then
level.Value = level.Value + 1
exp.Value = 0
end
end
local playerUserId = "player: "..player.UserId
local data
local data2
local data3
local success,errorMessage = pcall(function()
data = dataStore1:GetAsync(playerUserId)
data2 = dataStore2:GetAsync(playerUserId)
data3 = dataStore4:GetAsync(playerUserId)
end)
if success then
coins.Value = data
level.Value = data2
exp.Value = data3
print("Loaded in "..player.Name.." and their stuff.")
else
warn(errorMessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "player: "..player.UserId
local data = player.Data.Coins.Value
local data2 = player.Data.Level.Value
local data3 = player.Data.Level.Exp.Value
local success,errorMessage = pcall(function()
dataStore1:SetAsync(playerUserId, data)
dataStore2:SetAsync(playerUserId, data2)
dataStore4:SetAsync(playerUserId, data3)
end)
if success then
print("Saved data")
else
warn(errorMessage)
end
end)

3 comments
Put your while wait(1) do function below your data loading.
It's being looped so it never reached your loading part.
Thank you so much, dude! It's been an issue for quite a while and now it will be the least of my concerns now. <3333