How would I tell the player if the RemoteEvent was a success?

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.

What to tell the player if a remote event failed?

Just have a popup or something that says “(whatever requested ex. Saving) failed please try again”

You can either use a pcall, or you can use FireClient()

for example if a person typed in 3 as an answer to 1+ 1 then you would fire the client and tell them that it is wrong

server script:

mathqs.OnServerEvent:Connect(function(player, answer)
    if answer == 2 then

    else
        mathqs:FireClient(player)
    end
end)

local script:

mathqs.OnClientEvent:Connect(function()
    print("Sorry, the answer is wrong")
end
1 Like

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.

1 Like

I corrected my post, thanks for letting me know.