#need help with simple script

1 messages · Page 1 of 1 (latest)

kindred dagger
#
local serverscriptservice = game:GetService("ServerScriptService")

local manager = require(serverscriptservice.playerdata.manager)
local Template = require(serverscriptservice.playerdata.Template)
local profileservice = require(serverscriptservice.libs.ProfileService)

local KICK_DATA = "je kanker data doet het niet msg mij op discord"

local function CreateLeaderstats(player: Player)
    local profile = manager.Profiles[player]
    if not profile then
        return
    end
    
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    
    local clicks = Instance.new("NumberValue", leaderstats)
    clicks.Name = "Clicks"
    clicks.Value = profile.Data.clicks
    
    local gems = Instance.new("NumberValue", leaderstats)
    gems.Name = "gems"
    gems.Value = profile.Data.gems
    
end

local profileStore = profileservice.GetProfileStore("test", Template)
local function LoadProfile(player: Player)
    local profile = ProfileStore:LoadProfileAsync("Player_" .. player.UserId)
    if not profile then
        player:Kick(KICK_DATA)
        return
    end 
    
    profile:AddUserId(player.UserId)
    profile:Reconcile()
    profile:ListenToRelease(function()
        manager.Profiles[player] = nil
        player:Kick(KICK_DATA)
    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)``` whats the problem i dont understand can anyone help?
unborn tapir
#

the error means you tried to do ⁨nil.Instance⁩ on line 59

kindred dagger
unborn tapir
#

fixing it involves .. y'know, not indexing a nil value

kindred dagger
unborn tapir
#

is that line 59?

kindred dagger
#

i fixed it

burnt tigerBOT
#

studio** You are now Level 3! **studio

kindred dagger
#

i forgot a capital P