Could use a devs eye

we are having issues with this code for mechanics.

RegisterNetEvent(‘upgradeEngine’)
AddEventHandler(‘upgradeEngine’, function()
local plyCoords = GetEntityCoords(GetPlayerPed(-1), false)
local vehicle = ESX.Game.GetClosestVehicle(plyCoords)
-–SetVehicleModKit(vehicle, 0)
local props = {
modEngine = 1

}


upgrade(vehicle, props)
end)

function upgrade(vehicle, props)
ESX.Game.SetVehicleProperties(vehicle, props)
end
ESX.RegisterUsableItem(‘engineBasicTuningKit’, function(source)

local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem('engineBasicTuningKit', 1)

TriggerClientEvent('upgradeEngine')
end)

` no errors throw what so ever. Uses the item as well. Just the actual setting of the mod doesnt’ happen Assuming

ESX.Game.SetVehicleProperties(vehicle, props)

Is what isnt’ working right, or the way I’m passing the properties? I really don’t know liek I said I dont’ get errors.

it’s setting up a useable item, that when used grabs closest vehicle and attempts to apply a modkit, specifically the enginemodkit to upgrade the engine just as in LScustoms

It’s quite clear that you copy-pasted most of this. I get that it’s easier but that’s how vulnerabilities spread. Please, code with caution!

Anyway, in your server file you have this bit of code:

TriggerClientEvent('upgradeEngine')

This is not the correct way to use that function. As you can see here, you need to pass the playerId of the player you want to send the event to. That would be the source variable in the context of your item callback so what you want to do is:

TriggerClientEvent('upgradeEngine', source)

I do suggest you take a thorough look through docs.fivem.net before releasing anything or fully opening a server.

yes i copy pasted it from my lead dev and ty ill pass this to him now cheers