Remote function not working?

I am so confused right now. I have a remote function that was supposed to return info from a module script to a local script, because local scripts cant detect changes in module scripts at runtime without this. I did this method in another situation with another script and it worked fine. Created a new remote function and it doesn’t work this time? I’ve tried everything at this point and even this basic one doesn’t work:

In the local script, the remote function is a child of the script:

local func = script.Func

local function Testing()
	print("Invoking")
	local funcNotWorking = func:InvokeServer()
	print(funcNotWorking)
end

Testing()

In the script that is a child of the remote function:

local func = script.Parent
func.OnServerInvoke = function(player)
	return "Invoked"
end

There is no errors given at all, just straight up stops the entire script. Everything after invoking the remote function will not run. Any help?

1 Like

Did you call the Testing() function at all?

Yes sorry forgot to add that, the first print statement works but nothing after the invoke.

There is nothing else in the function…

The print statement after the invoke does not work, the print before it does. This is just a basic example though anything ive tried after it does not work. Just trying to simplify because nothing has solved my problems

My bad there was a misunderstanding on my part, can you add a print on the server side where it returns?

local func = script.Parent
func.OnServerInvoke = function(player)
        print("yup")
	return "Invoked"
end

Added, does not print anything, whole invoke just isnt working

Any errors? Where did you put the local script?
Oh wait I see you put the remotefunction in the local script and the server script inside the remote function??? Wha-
Put the server script in serverscriptservice and the remote function in replicatedstorage and the local script in like player gui or starterplayerscripts.

Does not change anything, I also did this method before and it worked fine. Helps to keep me organized

client

local reply = game.ReplicatedStorage:WaitForChild("RemoteFunction"):InvokeServer()
print(reply)

server

game.ReplicatedStorage:WaitForChild("RemoteFunction").OnServerInvoke = function(plr)
	print("hi")
	return "Invoked"
end

Can I ask where these scripts and the RemoteFunction are located?

1 Like