Hello, i am new to profileservice. I am trying to learn how to use it for future creations but I have a problem with it. The profile data, it just returns as nil and doesnt return any of the profile data. Any idea on what i did wrong?
Players = game:GetService("Players")
local ProfileService = require(game.ReplicatedStorage.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(
"Player",
{
money = 0;
}
)
local Profiles = {}
local function onPlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync(
"Player_" .. player.UserId,
"ForceLoad"
)
if profile then
print("player added")
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick()
end)
if player:IsDescendantOf(Players) then
Profiles[player] = profile
print("isdesc of")
else
profile:Release()
end
else
player:Kick("no profile detected")
end
end
local function onPlayerRemoving(player)
local profile = Profiles[player]
if profile then
profile:Release()
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
local DataManager = {}
function DataManager:Get(player)
local profile = Profiles[player]
if profile[player] then
print("profile data")
return profile.Data
end
end
return DataManager