Remote functions not returning anything and yielding forever?

Hello! This is my first time posting here :slight_smile: and this is the best time for this. Well it’s perfect timing but it would have been better without that bug.
My bug is about RemoteFunctions, see more below!
Note: I reported this bug to the support but I want your thoughts and maybe some useful ideas from you guys!

I just found out that everything about invocation (events & invoke functions) does not work.

  1. What do you want to achieve? The example remote function should be able to be invoked but seems like it does not work in any ways, but they’re found in their location.

  2. What is the issue? Include screenshots / videos if possible! The RemoteFunction is not invoked, so it yields the script forever and it does not return anything. But to add something here, I’m not the only one experiencing this and some other events does not get fired like RemoteEvents.OnClient/ServerEvent and BasePart.Touched events. This bug comes suddenly, and no way to fix it. Here’s a video of this bug (from me): Weird glitch… - YouTube

  3. What solutions have you tried so far? I did look for solutions, some people had this issue in 2021 & 2022 but not this year, also I looked at their solution but most of them didn’t have a single solution, and those that had a solution didn’t work for me. Seems like that bugs is here again.

So, I’ll sumarize it and give you the code if you want to know the scripts: The RemoteFunctions / RemoteEvents etc don’t get invoked and there is no error messages, I looked everywhere I could but the solutions didn’t work or there was no solution and I tried all of them but didn’t work.
Here’s the script that handle the RemoteFunction (in a Server script in ServerScriptService)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

--Some code here

remoteFunctions.GetTower.OnServerInvoke = function(player, towerName, securityKey) --If you're wondering why I'm using "security key", it's just to prevent exploiters to always place towers. The key is randomly generated for each client then sent to the server via a remote event that does not work.
	print(securityKey == nil, towerName == nil) --This message does not get logged because this remote function does not get invoked
	if towerName and securityKey then
		local playerDataFolder = ServerStorage:WaitForChild("PlayersData"):FindFirstChild(player.UserId .. "." .. player.Name) --This folder does not get created for some reason. I'll explain this issue here: Instance.New does not work along with this issue. I didn't report this to Roblox support so it would been nice you could help me with it.
		local rsPlayerDataFolder = ReplicatedStorage:WaitForChild("PlayersData"):FindFirstChild(player.UserId .. "." .. player.Name) --Same for this
		if securityKey == playerDataFolder:FindFirstChild("SecurityKey").Value then
			local towers = ServerStorage:WaitForChild("Towers") --So I don't know if there's anything happening.
			if towers:FindFirstChild(towerName) then
				local cloned = towers:WaitForChild(towerName):Clone() --Don't care if it exists or not, what matters is that it serves a purpose.
				cloned.Parent = rsPlayerDataFolder
				return cloned
				print("Not found")
	return nil

Here’s the script that sends the request:

--Local script in a ScreenGui.
function AddPlaceholderTower(name : string)
	print("AAAAAA") --This gets logged
	print(#ReplicatedStorage:WaitForChild("RemoteFunctions"):GetChildren()) --This shows 2
	tower = remoteFunctions:WaitForChild("GetTower"):InvokeServer(name, securityKey)
	print("Invoked") --Does not get printed so this means the remote function does not work.
	if tower then
		print("Tower exists")
		tower.Parent = workspace.Towers
		for i, object in ipairs(tower:GetDescendants()) do
			if object:IsA("BasePart") then
				object.CollisionGroup = "Mob"

So like I said, this issue appeared in 2021 and 2022 but seems like now 2023, since the 6th of this month (September 2023). So maybe the servers are having some problems? Well, at least, you can give me some tips that I can try to fix this issue!
Thanks for any help and I remind you that this is my first post in the devforum!
Tell me if I forgot some details!

Use this script as a real check-up it uses pcall just to be sure (only to make sure what really is going on):

function AddPlaceholderTower(name: string)
    print("AAAAAA") -- This gets logged
    print(#ReplicatedStorage:WaitForChild("RemoteFunctions"):GetChildren()) -- This shows 2

    local success, result = pcall(function()
        return remoteFunctions:WaitForChild("GetTower"):InvokeServer(name, securityKey)

    if success then
        if result then
            print("Tower exists")
            result.Parent = workspace.Towers -- change this if you have to

            for i, object in ipairs(result:GetDescendants()) do
                if object:IsA("BasePart") then
                    object.CollisionGroup = "Mob"
            print("Tower not found")
        print("Error invoking remote function:", result)

1 Like

Are the remote events in ServerStorage? If so, the client can’t access them.

edit: just a random guess ngl - I will edit again if I find anything else wrong

No, it is in “ReplicatedStorage”.

I’ll check that out tomorrow! Thanks for your help!

Ok, so I tried your solution and seems like it also stays yielded. Nothing happens
The “3” is right before it requests the remote function, so this means it’s still broken. There’s no other log messages from the client.

Edit: I’ve just found that everything about invocation (like Events and invoke functions) does not get invoked at all.

I find your use of pcall() not necessary.
Simply use a local variable instead of a return statement.

local result = remoteFunctions:WaitForChild("GetTower"):InvokeServer(name, securityKey)

I’ve found something really interesting! : The remote functions & remote events, etc work on new places, but when I copied all my code they didn’t work anymore. Here’s my sample code that I used to check if the RemoteFunctions etc work:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

    print(player.Name, "from RemoteEvent") --Logs Nilsou21 from RemoteEvent

ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player)
    print(player.Name, "from RemoteFunction") --Logs Nilsou21 from RemoteFunction.

In a LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")


Those did work, but then when I copied all my code, they didn’t work anymore… Any thoughts why this happens??

Yeaah this happens when the runningcontext property isnt changed in the SERVER script, Its very annoying.

Check the properties in the script and change it.

Had issues with it before, When you put a script in a place besides serverscriptservice. or something, RemoteEvents and stuff wont recieve, fire, or blah blah.

Or relocate the script in serverscriptservice, Whatever suits you.
(not sure if this is your problem, i speedread this)

1 Like

It’s in ServerScriptService, what’s weird is that something in my code makes the events not working. I don’t know what, why won’t it make them work and simply why isn’t there any error?
But I’ll try your solution!
Thanks for your help :grinning:

1 Like

Wait a second! For some reason, the script that handles the remote events etc does not work. I changed script and everything worked. What is causing this? I’m putting everything like RemoteFunction handling in another script. And it works.

So, to explain: Instead of having RemoteEvents, RemoteFunctions and other events handling in the same script, I put each of them in another script and it works. Why? I don’t know. This never happened for me before. So keep it mind that when this happens, don’t hesitate to change script.

Also, thanks for you guys help! You are really nice!

1 Like

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