Using remote function for two different tasks not working!

So i’m trying to use the same remote function for multiple Tasks but it just seem not working

also there’s NO ERRORS on the output

here’s the script :

--- / Onclient / ----
----- First taks ------
local result = GeneralDataCheck:InvokeServer("CheckingPotionsData",thepotion)
----- Second task ----- 
local result = GeneralDataCheck:InvokeServer("CheckingIfPlayerHaveCastle" )
-----/ On Server / ---
----- First Task ------
GeneralDataCheck.OnServerInvoke = function(plr,taske,thepotion)
	print("invoked")                    --<<<-- DOESN'T PRINT
	if taske == "CheckingPotionsData" then
		-- whatever
	end
end
----- Second Task ------
GeneralDataCheck.OnServerInvoke = function(plr,taske)
	print("invoked")                  ---<<- ONLY THIS PRINT "INVOKED"
	if taske == "CheckingIfPlayerHaveCastle" then
		-- whatever
	end
end


You can only assign one function to a server invoked, use if and elseif statements:

something.OnServerInvoke = function(plr, something)
  if something == "" then
    DoSomething()
    elseif something == "g" then
    DoSomethingElse()
  end
end

Pls don’t mind the bad formatting, I wrote this on my phone.

2 Likes

thx i really didn’t think of that …
bc with remote events i was just firing the same event twice so i was confused why it doesn’t work woth remote functions
thanks anyway this worked

1 Like