I don't know why my values for slashes and gems aren't showing up as leader stats, Could anybody please tell me why?
Data Code:
local ServerScriptService = game:GetService("ServerScriptService")
local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local ProfileStore = ProfileService.GetProfileStore("Production", Template)
local KICK_MESSAGE = "Data issue, try again later. If the issue persists please contact us!"
local function CreateLeaderStats (player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Slashes = Instance.new("NumberValue", leaderstats)
Slashes.Name = "Slashes"
Slashes.Value = profile.Data.Slashes
local Gems = Instance.new("NumberValue", leaderstats)
Gems.Name = "Gems"
Gems.Value = profile.Data.Gems
end
local function LoadProfile(player: Player)
local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
if not profile then
player:Kick(KICK_MESSAGE)
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
player:Kick(KICK_MESSAGE)
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
CreateLeaderStats(player)
else
profile:Release()
end
end
for _, player in Players:GetPlayers() do
task.spawn(LoadProfile, player)
end
Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(player)
local profile = Manager.Profiles[player]
if profile then
profile:Release()
end
end)```
** You are now Level 1! **