Do I Need a Remote Function for This?


A bit of a conceptual one today.

Essentially, I’m trying to make a sonar device for players to use. When they press the ‘E’ key on their keyboard, a pinging sound plays locally, and a script checks to see if there are any collectable items nearby.

Currently, I’m trying to make all of this happen via the localscript that wires the keybind to the action, but I’m wondering if that’s not possible to achieve with a localscript.

local function handleAction(actionName, inputState, inputObject)
    -- this is a localscript
    -- could the above be done using code that is executed inside of here?

ContextActionService:BindAction(ACTION_PING, handleAction, true, Enum.KeyCode.E)

Thanks for any and all help, and let me know if you need any more info.

You do not need a remote function if the client knows the position of all collectable items.

If the client does not, you will need to implement a way for the server to tell the client what items are nearby (probably with a remote function).

1 Like

Yes you can do all of this, locally, if this earns you cash or something like that you may want to change it to a remote event to help prevent rudimentary hacking.

1 Like