:InvokeServer doesn't work for some reason?

So what I am trying to achive is invoking the server with a couple arguments

The remote function worked at first but then suddenly out of the nowhere it just broke
I don’t really know if this is a Studio issue or something I messed up here.
Sometimes it returns the player and next try it won’t work anymore
Most of the time it prints Client: nil nil when its supposed to print Client: MlT3X nil

Note: I’m just returning the player for testing purposes, later on when the issue is fixed then the code will be changed


Literally pressing stop in studio and trying it again without changing the code:



equip_asset = replicatedStorage:WaitForChild("Remotes", 10):WaitForChild("EquipAsset", 10)
button_listener = function(button, category, data)
		local equipped = button.ImageLabel.Visible
		local args = table.pack(button.Name, category, equipped, data)
		local Invoke, msg = equip_asset:InvokeServer(args)
		warn("Client:", Invoke, msg)
		if Invoke == true then
			print("invoke true")

Server: (it always prints here so that’s why I am wondering why it doesnt print called sometimes)

local replicatedStorage = game:GetService("ReplicatedStorage")
replicatedStorage:WaitForChild("Remotes", 10):WaitForChild("EquipAsset", 10).OnServerInvoke = function(player, ...)
	return player

The first value of the parameters inInvokeServer is the player who invoked the server, not the button which the player clicked on. I suggest you add a player parameter in the function like from this function(button,category,data) to this: function(player,button,category,data) and when you call the invokeserver, you will not have to define the player who invoked the server. I hope this helps.

1 Like

The problem is, it doesnt even print called, it only does it sometimes. I’m really clueless.
I also tried replacing :WaitForChild with :FindFirstChild, which didn’t fix the issue

Okay, now I’ve seen your whole script lol. I messed up with the server script and local script. Try removing return player since you’re running that return in a local script. You can access game.Players.LocalPlayer in a local script in case if your local script needs the player

No no, as I said. I am returning player for testing purposes. There’s nothing I want to do with the player itself. Just using it for debugging.

For now it doesn’t matter if the remote function is not returning anything. And as said as well print("called") is not even running when calling the remote function which is confusing

Alright. You have added another parameter in WaitForChild() which is a number. You set that value to 10 for each of them. Remove that since you’re only waiting 10 seconds for them to load. We want the script to yield until it is loaded, not after 10 seconds.

I have removed the 10 seconds parameter, even now it is not working 100%
It doesn’t even yield or anything. It doesn’t invoke at all. I even printed the RemoteFunction itself :joy:
Im pretty sure its a Server-Side issue



and press that :black_square_button:

button_listener is called for every button, the button_listener is not causing any issues here
a print under button_listener = function(button, category, data)

and > It always logs warn("Client:", Invoke, msg)

i think i fixed it

--local script
replicatedStorage = game.ReplicatedStorage
local equipped = true
local args = table.pack('hello', '#help-and-feedback:scripting-support ', equipped, 'data = nvsihvsisv')
local Invoke, msg = game.ReplicatedStorage.Remotes.EquipAsset:InvokeServer(args)
warn("Client:", Invoke, msg)
if Invoke == true then
	print("invoke true")
local replicatedStorage = game:GetService("ReplicatedStorage")

replicatedStorage:WaitForChild("Remotes", 10):WaitForChild("EquipAsset", 10).OnServerInvoke = function(player,parameter1)
	return player
called  -  Server - Script:4
Client: Qin2007 nil  -  Client - LocalScript:6

my explorer

Am I forced to put the LocalScript in StarterPlayerScripts? Anyways it doesnt work 100% as well. Im convinced its a Studio issue. I did not see this issue in-game for now

i’ve tried the other LocalScript containers
and starterGui
work all

I tried this on a new place, worked I guess. So I assume it has to be something with my system? I have been debugging for like 2 hours now and yet I couldn’t find the issue. Its a really strange behaviour. I guess I’ll have to remake everything once again :woozy_face: I appreciate the help though!