Hey DevForum, I’m creating a ProfileService script, and while there’s a “[ProfileService]: Roblox API services available - data will be saved” print in the output, it just doesn’t save.
I thought it was because I was the only person in the server, so I might have to add a BindToClose function, but it didn’t work either.
Here is the main script, other than the ProfileService module:
local Players = game:GetService("Players")
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("1.0.0", Template)
local KICK_MESSAGE = "Sorry, we're having difficulties trying to load your data. Try again shortly."
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 Speed = Instance.new("IntValue", leaderstats)
Speed.Name = "Speed"
Speed.Value = 0
local Wins = Instance.new("IntValue", leaderstats)
Wins.Name = "Wins"
Wins.Value = 0
--[[
OH SKIBBBB
]]--
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)
There are 2 other module scripts called “Template” and “Manager.” Let me know if you want to see them