Introduction
Hello!
Everybody knows remote functions, That function that returns a value and the client waits for it. But this time it is something different, I made a remote function to move the client script to somewhere else, but the client didn’t receive the thing that the server sent, even if there were no errors!
(Note, I already fixed this problem and this have workarounds, ex: using a remote event.
But I want to achieve this for other people if they have a similar problem)
Problem
I made a remote function to change the local script’s position, but roblox didn’t returned any value.
(The reason of why changing the position is that the server can put local scripts in the Player´s “PlayerGui” and get the script to load. After the script loaded (sent the request) it will move it to a different place so that when the player resets it doesn’t remove the script )
This is a big problem, and the reason why is because roblox doesn’t return the value when the script is moved. It also doesn’t say anything, no errors, no warnings, nothing! The server receives the confirmation that the information was sent even though it never reached the client, and the client is still waiting.
And there is no way to find what is wrong, because the value does return in the script, and it has no errors, the way I found it was “brute forcing” and removing line by line until I found it was the renaming.
(I know it sounds obvious, like “How do you expect it to return a value when moved?”, but think with me, how would you know if it says everything went successful? How would you think about it that time?
In my case, I had multiple if statements and checks, so the more obvious thing to do is to put a print after each one. But all of them worked, the request sent. I took so much time to realize this)
Solution?
There is no solution, apart from not doing that. Don’t move a script position in a remote function, use something that doesn’t yield. Like a remote event, and then send the result back with another remote event that the client picks up.
Conclusion
I hope you could learn something out of this, did something similarly happen? Or even something else! Like, for example, you can load local scripts any time you want by putting them in the player GUI folder!
Something I feel roblox should do is inform that the script was not found, say that it didn’t return or give some form of signal, because as of now it simply drops the request and ignores it, and the client keeps waiting for a response.