#hi

1 messages · Page 1 of 1 (latest)

dry cypress
#

hi can yall help me with this script

local ServerScriptService = game:GetService("ServerScriptService")

local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileStore)

local ProfileStore = ProfileService.GetProfileStore("Production", Template)


local KICK_MESSAGE = "Data issue, try again shortly, if issue persists, 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 clicks = Instance.new("NumberValue", leaderstats)
    clicks.Name = "Clicks"
    clicks.Value = Profile.Data.Gems
    
    
    local gems = Instance.new("NumberValue", leaderstats)
    gems.Name = "Gems"
    gems.Value = Profile.Data.Clicks
    
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:IsDescendentOf(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)

#

my leaderboard is not showing up and i keep get this error from the outpout. ServerScriptService.PlayerData.Data:8: attempt to call a nil value

#

s

hardy spire
# dry cypress hi can yall help me with this script ```local Players = game:GetService("Players...

Check these things:
a. Pathways

  • Are the variables beforehand actually referencing the correct instances?
    b. Check the Module
  • Does "Template" throw an error?
    c. Is it even a Module?
  • Is "Template" even a module
    d. Ensure that the module returns what it should
  • if it returns nil, it'll attempt to index nil

also, pro tip, the local function type check for CreateLeaderStats and LoadProfile should be
(player: Player)
not
(player: player)

Hope this helps

dry cypress
#

Template is a module and yes its returning template

#

For now nothing working i realy need help

rocky lantern
#

GetProfileStore does not exist, hence the attempt to call nil on line 8