print('starting hats')
function dataReady.OnClientInvoke(player)
print('hats')
end
Other LocalScript
print('starting faces')
function dataReady.OnClientInvoke(player)
print('faces')
end
The output prints both starting hats and faces, but only prints faces and not hates. The DataReady RemoteFunction fires when the data has fully loaded. So my guess is that OnClientInvoke only works from one localscript, but idk that doesnt make sense to do that
You typically use a RemoteFunction when you care about some return value, otherwise you can substitute that with a RemoteEvent call back and forth. If you could implement OnClientInvoke twice, and both implementations return something, what would the server get back?
RemoteFunctions are inherently 1:1. If you don’t want 1:1 but instead 1:many, use RemoteEvent communication instead.
In other words, you can only hook up one function to OnClientInvoke/OnServerInvoke at a time. So you generally might want to use multiple remote functions in a game.
I would like to note that OnClientInvoke does not automatically pass the Player Object unless you passed it with InvokeClient.
I would use a RemoteEvent in this case.
The problem is that you have multiple Scripts but for me I use only have a few so I don’t have the same problem, maybe you might want to consider that.
Although you can use 2 RemoteFunctions if you want.
From what I know it’s the same with all callback functions. Another example is MarketplaceService.ProcessReceipt; you can only hook up one function with it. To further clarify for OP, function dataReady.OnClientInvoke() is the same as dataReady.OnClientInvoke = function(). If you write it a second time, like it does here, it overwrites the first one.
If I write x.Value = 1, and then the line after write x.Value = 2, and then print(x) it’s never going to print 1. That is in essence what OP is trying to accomplish here. It doesn’t matter if it’s in a different script. Use a RemoteEvent!