:InvokeClient() no longer works? (SOLVED)

I had a game I worked for a while and I decided to make a shop for it. After triggering a proximity prompt the script would invoke the client who triggered it, and the localscript inside the shop GUI would bring up the gui itself. But suddenly it stopped working. :InvokeClient() no longer works.

When i close the game There is this message in the output:

Player Dun_FB disconnected during remote call to ReplicatedStorage.ShopEvent

This bug works in both robloxstudio and robloxclient.
image
image

I cant post in bug reports and i didnt really have anything except for this category sorry about that

1 Like

Use RemoteEvents.


A server should rarely invoke a client via RemoteFunction:InvokeClient() as it can be potentially game breaking. For client-only actions that don’t require a callback, like updating a GUI, a server-to-client remote event should be used instead. If RemoteFunction:InvokeClient() is used, risks include:

  • If the client throws an error, the server will throw the error too.

  • If the client disconnects while it’s being invoked, the RemoteFunction:InvokeClient() call will error.

  • If the client never returns a value, the server will hang forever.

2 Likes


it does fire the remote event now but i dont get why my localscript is not detecting it

Is connected not printing? Can you show the server script?

the script is in the prompt in workspace
image
image

and the localscript is inside the UI
image
image

I am 100% sure that there are no errors in the local script
edit: yes it never prints “connected”

Try

ReplicatedStorage.ShopEvent.OnClientInvoke = OpenShop

Are you ever assigning a callback function to .OnClientInvoke?

First of all, I heavily agree with what @SomeFedoraGuy said about using RemoteEvents instead of RemoteFunctions.

Secondly, your original screenshots use :InvokeClient() on the server, but .OnClientEvent on the client. If you were to use RemoteFunctions, then both of these should be Invokes, so the local script should be using .OnClientInvoke instead. But again, I advise against using RemoteFunctions in this scenario. And in your later screenshots, you corrected this inconsistency by changing :InvokeClient() to FireClient().

Lastly, assuming you are using the code in your latest screenshot and there’s no errors outside of the posted code preventing the rest of the code from running, there’s two potential issues I see here:

  1. Make sure ShopEvent is a RemoteEvent,not a RemoteFunction. FireClient uses RemoteEvents. InvokeClient uses RemoteFunctions.

  2. Players do not always have everything loaded in immediately. Due to this, in local scripts, sometimes you need to wait for things to exist. This could be happening with your ShopEvent remote. To fix this, simply change line 139 in your last screenshot to ReplicatedStorage:WaitForChild("ShopEvent") instead of just ReplicatedStorage.ShopEvent.

why don’t you just connect the local script to the proximity prompt when triggered bring up the UI. Instead of the server script you have now that then fires back to the client else you could just use the server script find the ui in the player and make it visible run your setup code on the Getpropertychanged signal for visible

there are only a few times you really need to use remotefunctions and you don’t always have to use remote events you can use attributes and propertychanges even tags are very useful instead of remote events

Thank you for the explanation, ShopEvent is indeed a remoteevent. I think an error would already pop up in the output if there was something wrong.

But I did do what you said anyway, Both of the scripts wait for shopevent but still local script doesnt connect the clientevent from shopevent.

What i am curious about is why this used to work and why is it not working anymore

Edit: By the way, it was not .OnClientEvent(), i took that screenshot after doing what TheTravellerChicken1 recommended me to do.
Plus, thats not even the problem. The problem was :InvokeClient() stopping working without me doing any change on the script.
Also, I have an older version of the game in a different place with the :InvokeClient() function. It still works there but not in this game. Maybe it is also related to games in some way?

This is because the function has a infinite yield and you leave while it is yielding, may I see the function?

I get what you mean
image
unfortunately that doesnt work either. I believe that I would definitely use this method instead if it worked back then

these are literally all I have

LocalScript
image

Script Inside the ProximityPrompt in workspace
image

You don’t need any remotes if your using a proximity prompt. Use Prompt.Triggered.

Yeah you are thinking simple but just to mention that this was literally the first thing i did for this localscript. If It worked I would use it

I found the line that stopped the whole script without informing in the output, Everything works properly now. Took 3 hours to find it

I probably should get back to being a solo developer

  • image
    Making a LocalScript search for an instance in ServerStorage breaks the script

Sorry for all the confusion lol :sweat_smile:
and thank you for your help, you saved my months of work

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