Remote function changes return every time the game starts with ProfileService

Hey everyone!

I am having issues with returning information from my ProfileService data to the client.
Every time the game starts, a few client local scripts look for a “GetInfo” function in my Save / Data manager to return the information client requires through a remote function

Looks likes this

--Client
local playerMoney = rfInfoGetter:InvokeServer("Money")
--Server
local function GetInfo(player: Player, category: string)	
	--yield while we dont have data		
	while not Profiles[player] do		
		task.wait()
	end
    if category == "Money" then
		return Profiles[player].Data.Money
    end
end

The problem is, this will sometimes return properly, sometimes return nil. And even if I loop in the client until that function returns something, it returns nil forever even after the profile did load.

I have tried:

I have tried:

Looping and firing the function every second

--Client
local playerMoney = rfInfoGetter:InvokeServer("Money")
if not playerMoney then
     while playerMoney == nil do
          playerMoney = rfInfoGetter:InvokeServer("Money")
          wait(1)
     end
end

Using a pcall and trying to fire the function again or return

local function MyFunction( NewPlayerMoney)
--Client
local success, error = pcall(function()
	playerMoney =   NewPlayerMoney or rfInfoGetter:InvokeServer("Money")
       if playerMoney >= billboard.Value (This fails)
end
If error then 
    NewPlayerMoney = rfInfoGetter:InvokeServer("Money")
    myFunction( NewPlayerMoney)
end
end

I have also tried delaying the load of this local script only after the server itself fires an event which lets this run

The most concering thing is that this is not stable or repeatable, some times it loads, some times it doesn’t and I have no way to efficiently replicate it. Regardless of how much time I give the server or the client.

Something important to note is that when this happens, all of the players in the server have the same issue but only for the money, not other GetInfo() returns So its not that the profile service failed.

If anyone knows how to solve this or has any ideas it would be really appreciated

I was able to find the solution. After a long search found this and it was indeed the reason why it was not working:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.