Hello!
I am using profile service to check if players own something and then put it in its inventory as they join the game. I came across a problem where the value returns as nil when checking if they own something. I initially used the PlayerAdded event but then I used the bindable event where I wait until data is loaded in the profile service handler.
local ServerStorage = game:GetService("ServerStorage")
local EffectFolder = ServerStorage:WaitForChild("Effects")
local SSS = game:GetService("ServerScriptService")
local Profilecache = require(SSS.SavingSystem.DataManager)
local RS = game:GetService("ReplicatedStorage")
local CardsFolder = RS:WaitForChild("EffectCards")
local DataLoadedEvent = game:GetService("ReplicatedStorage"):WaitForChild("Bindable"):WaitForChild("DataLoaded")
local function LoadInventory(Player)
print(Player)
local PlayerProfile = Profilecache[Player]
for i, v in pairs(EffectFolder:GetChildren()) do
print(PlayerProfile.Data.RayEffect)
if PlayerProfile.Data[v.Name] == false then
local EffectClone = CardsFolder[v.Name]:Clone()
EffectClone.Parent = Player.PlayerGui.Shop.Inventory.MainFrame.Effects
end
end
end
DataLoadedEvent.Event:Connect(function(Player)
print("data is loaded :)")
wait(3)
LoadInventory(Player)
end)