Lots of replys thanks for that, but I have never used a Profile Service before so here is my script anything wrong?
local Players = game:GetService("Players")
local ProfileService = require(script.Parent.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(
"Player",
{
Coins = 0;
GoldenHookOwned = false;
GoldenHookEquipped = false;
TPoseOwned = false;
TPoseEquipped = false;
}
)
local Profiles = {}
local function OnPlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync(
"Player_" .. player.UserId,
"ForceLoad"
)
if profile then
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick()
end)
if player:IsDescendentOf(Players) then
Profiles[player] = profile
else
profile:Release()
end
else
player:Kick()
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 then
return profile.Data
end
end
return DataManager
Why are you using a module for ProfileService? It should be kept in the main script so you can easily modify it with playerProfile.Data.Whatever = true. I handle ProfileService in my main script for data handling.