If the player fires a RemoteEvent and the server denies the request how can we send that information back to the player to notify them?
I used a RemoteFunction to check the requirements so that I can then send the information back to the player then allow the RemoteEvent to be fired but the RemoteFunction apparenly you cannot send information stored in a LocalScript to a RemoteFunction.
Alternatively, if you wanted to tell the client the status, or give it info upon request to the server, you can use RemoteFunctions which has the same general concept as RemoteEvents.
Example
Using the same example as TOP_Crundee123:
Server
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player, answer)
if answer == 2 then
return true
else
return false
end
end
Client
local answer = game.ReplicatedStorage.RemoteFunction:InvokeServer(plrResponse)
if plrResponse then
print("correct!")
else
print("try again")
end
In the example, PlrResponse is everything that comes after the return statements in the server code. You can return anything back to the client, tables, strings, bools, whatever.
It is important to note that RemoteFunctions will yield the code, whereas RemoteEvents won’t.
RemoteEvents and RemoteFunctions are sufficiently different in functionality not to call them the same. The general concept of being used to cross the server-client boundary is the same but not their actual functions.
RemoteEvents are designed to be one-way cross-environment signals. They run asynchronously in code, so threads will not yield upon firing. You can connect multiple listeners to it.
For RemoteFunctions, they are designed to make a round trip where one environment invokes another and awaits a response. RemoteFunctions can only hold one function and it can’t interact and run multiple instances of it’s function - previous invocations need to finish.