Anybody know why I would be getting this error? When I play my game, I am getting this error but under my player leader stats it has the values in the error.
I need more context can you show the script.
local function setupPlayerData(player)
notificationEvent:FireAllClients(player.DisplayName.." Joined The Server!", Color3.new(1, 0.913725, 0.705882))
local playerUserId = player.UserId
local data
local success = pcall(function()
data = playerData:GetAsync(player.UserId)
end)
if success then
if data then
sessionData[playerUserId] = data
else
sessionData[playerUserId] = {
Coins = 0,
Prestige = 0,
Stages = 0,
code = "",
redTrail = false,
blueTrail = false,
rainbowTrail = false,
Ballon = false,
Speeder = false,
MachineBallon = false,
equippedTrail = "",
setting = {
TurnOnMusic = true,
TurnOnPopup = true,
ShowPlayer = true,
ShowTrail = true
}
}
end
end
if len(deafult) > len(sessionData[playerUserId]) then
for i, v in pairs(deafult) do
if sessionData[playerUserId][i] == nil then
sessionData[playerUserId][i] = v
end
end
end
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Parent = leaderstats
local Stage = Instance.new("IntValue")
Stage.Name = "Stage"
Stage.Parent = leaderstats
local Rebirth = Instance.new("IntValue")
Rebirth.Name = "Prestige"
Rebirth.Parent = leaderstats
Coins.Value = sessionData[playerUserId]["Coins"]
Stage.Value = sessionData[playerUserId]["Stages"]
Rebirth.Value = sessionData[playerUserId]["Prestige"]
local trailfolds = {
sessionData[playerUserId].redTrail,
sessionData[playerUserId].blueTrail,
sessionData[playerUserId].rainbowTrail
}
game.ReplicatedStorage.ShopEvent:FireClient(player, "Trails", trailfolds)
repeat wait() until player.Character ~= nil
player.CharacterAdded:Connect(function()
setupPlayerCharacter(player)
end)
setupPlayerCharacter(player)
BadgeModule.AwardBadge(player, "You Played")
settingEvent:FireClient(player, sessionData[playerUserId].setting)
end
There’s two leaderstats folders being created. The script is likely searching through the one on top.
I can’t find where the other folder is being created is there an easy way to find out?
Not entirely sure why this runs twice, we need to see the code that calls setupPlayerData(). Also you don’t handle both failures when accessing the datastore:
if success then
if data then
else
end
end
What happens if success==false
(i.e. the DataStore is not currently accessible, but the player may or may not have data). If you go ahead and assign new data and then save it the player could lose everything they have, simply because the DataStore was offline and you never checked.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.