I encountered an error while trying to add something to a duty script

Here is the error code:
Error parsing script @PoliceEMSActivity/server.lua in resource PoliceEMSActivity: @PoliceEMSActivity/server.lua:77: expected near ‘[’

I am trying to add a system when you go on duty it adds you to the RP-Radio channel 1 automatically. I also made it so RP radio channel 1 is private.

Here is the PoliceEMSActivity Server.lua that has been modified.

TriggerClientEvent(‘PoliceEMSActivity:GiveWeapons’, source);
TriggerClientEvent(exports:[“rp-radio”]:Radio.Toggle);
TriggerClientEvent(exports:[“rp-radio”]:GivePlayerAccessToFrequencies(1));
TriggerClientEvent(exports:[“rp-radio”]:SetRadioEnabled(true));
TriggerClientEvent(exports:[“rp-radio”]:Radio.Toggle;

Hi there,

Looks like you’re dealing with a simple error here – incorrect usage of the export function.

  1. Exports don’t need to be triggered using TriggerClientEvent.
  2. The correct syntax for exports is exports['resourceName']:functionName(arg1, ...).
  3. Exports are client-side and cannot be executed server-side.

In your server.lua file:

TriggerClientEvent('PoliceEMSActivity:GiveWeapons', source);
TriggerClientEvent('Topher007:EnterRadio', source);

And in your client.lua file:

RegisterNetEvent('Topher007:EnterRadio', function()
    exports["rp-radio"]:SetRadio(true)
    exports["rp-radio"]:SetRadioEnabled(true)
    exports["rp-radio"]:AddPlayerToFrequency(1)
end)

Theoretically, you’ll need to do the same for the off-duty scenario as well (logically speaking). I’ve attached two files where this is still included. You just need to incorporate them yourself.

client.lua | server.lua

Let me know if you need further clarification or assistance with anything else!