I have a obby game I am working on, and i am trying to load Player leaderstats using GetAsync… it will not load
Heres my script:
local obbyStages = workspace:WaitForChild(“Stages”)
Players = game:GetService(“Players”)CurrentCheckPoint = {}
local CheckPointSpawn = game.Workspace.Stages:GetChildren()local DataStoreService = game:GetService(“DataStoreService”)
local GameDATA = DataStoreService:GetDataStore(“PlayerExperience”)
function newPlayer(plr)
local stats = Instance.new(“Folder”)
stats.Name = “leaderstats”
stats.Parent = plrlocal Stage = Instance.new(“IntValue”)
Stage.Name = “Stage”
Stage.Parent = stats
Stage.Value = 1local data
local success, currentExperience = pcall(function()data = GameDATA:GetAsync(plr.UserId, plr.leaderstats.Stage.Value)
end)
if success then
print(data)else
print(“Data couldnt load”)end
local TempChar = plr.Character
if TempChar ~= nil then
NewCharacter(plr, TempChar)
end
plr.CharacterAdded:connect(function(Char)
NewCharacter(plr, Char)
end)end
function NewCharacter(plr, Char)
local TempCurrentCheckPoint = plr.leaderstats.Stage.Value
if TempCurrentCheckPoint ~= nil then
local TempCheckPointSpawn = workspace.Stages:WaitForChild(TempCurrentCheckPoint)
repeat wait () until Char.PrimaryPart ~= nil
Char.PrimaryPart.CFrame = TempCheckPointSpawn.CFrame + Vector3.new(0,1,0)
end
endPlayers.PlayerAdded:connect(function(plr)
newPlayer(plr)
end)