Okay well this is interesting, first time using Profile Service and watched two tutorials on it. Here is the issue I am encountering.
Issue: No profile is being found upon changing cash or any value
Module Script for changing Cash
local module = {}
module.Profiles = {}
function module:AdjustCash(player, amount)
local profile = module.Profiles[player]
if not profile then warn("no profile") return end
profile.Data.Cash += amount
player.leaderstats.Cash.Value += profile.Data.Cash
end
return module
–The debugging script (Server Script)
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local PlayerData = require(ServerScriptService.PlayerData.Manager)
while true do
for _, player in pairs(Players:GetPlayers()) do
PlayerData.AdjustCash(player, 5)
end
task.wait(1)
end
And Finally my Data Server Script
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Template = require(script.Parent.Template)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local Manager = require(script.Parent.Manager)
--Set to Live when publishing
local ProfileStore = ProfileService.GetProfileStore("Live", Template)
local function GiveLeaderstats(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Cash = Instance.new("NumberValue",leaderstats)
Cash.Name = "Cash"
Cash.Value = profile.Data.Cash
local Level = Instance.new("NumberValue", leaderstats)
Level.Name = "Level"
Level.Value = profile.Data.Level
end
local function PlayerAdded(player: Player)
local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
if profile == nil then
player:Kick("An error went wrong loading your data. Contact us if the issue persists.")
return
end
-- Player Profile was loaded Successfully
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
player:Kick("An error went wrong loading your data. Contact us if the issue persists.")
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
GiveLeaderstats(player)
else
profile:Release()
end
end
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(PlayerAdded, player)
end
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(function(player: Player)
local profile = Manager.Profiles[player]
if not profile then return end
profile:Release()
end)
It seems to break after i added my function for Adjusting cash, although i highly doubt this can be the issue since the other tutorial i used my profile was never found, I have played both in Roblox and Roblox Studio and still receive the “no profile” error
Edit: Studio Access to API Services is enabled also.