RemoteEvent or RemoteFunction?

Hello, This is probably a stupid question but i’m trying to make a function that can be called from any server or local script and was wondering if a RemoteEvent or RemoteFunction would be better? I tried looking at the creator documentation for these but it doesnt say anything about server-server or server-sever/client. Maybe I’m stupid but yeah.
image

2 Likes

If you need server-server or client-client communication, BindableEvents are going to be your friend.

For your case, however, you can use a RemoteFunction that is stored in ReplicatedStorage. Just keep in mind server to client back to server has serious risk implications (never trust the client!).

-- Client
local Response = RemoteFunction:InvokeServer(args)

-- Server
RemoteFunction.OnServerInvoke = function(player, args)
3 Likes

Yeah I need it for a function to add something to players inventory’s so security is definitely a must.

If you need the server to return something to the client: RemoteFunction. If you don’t: RemoteEvent

1 Like

The first part of the documentation you posted really answers all your questions very well. If you need to return a value from the function you are calling then you use a RemoteFunction as RemoteEvents do not return values. The documentation also states in the early INFO bubble to use Bindable Events when doing server-server or client-client.

1 Like

You’re going to want client to server to client communication, which is exactly what I’ve outlined in my prior post.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.