So i get that ped but not weapon.

client script:
RegisterCommand(“FBI”, function(source, args)
local playerPed = GetPlayerPed(-1)
local model = GetHashKey(“s_m_m_fibsec_01”)

RequestModel(model)

while not HasModelLoaded(model) do
    Wait(0)
end

SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)
Citizen.Wait(1000)
RegisterNetEvent("FBI:give")

end, false)

server script:
RegisterNetEvent(“FBI:give”, function()
local player = source – Get the player’s server ID who triggered the event
local playerped = GetPlayerPed(player)

local weaponName = "WEAPON_REVOLVER"
local weaponHash = GetHashKey(weaponName)

-- Check if the weapon is valid
if IsWeaponValid(weaponHash) then
    GiveWeaponToPed(playerped, weaponHash, 120, false, true)
    TriggerClientEvent("chatMessage", player, "^2You received a weapon: " .. weaponName)
else
    TriggerClientEvent("chatMessage", player, "^1Invalid weapon: " .. weaponName)
end

end)

– Function to check if a weapon is valid
function IsWeaponValid(weaponHash)
return weaponHash ~= 0 and weaponHash ~= nil
end

fxmanifest:
fx_version ‘cerulean’
games { ‘gta5’ }

client_scripts {
“Client/Main.lua”
}

server_scripts {
“Server/Server.lua”
}

And i’m new in coding.

Please share your code in proper code blocks.
Example:

myfile.lua
```lua
print(“Works!”)
```

Output:
myfile.lua

print("Works!")



The issue is on the client side while the command handler is run. You try to register the event as net event? I think what you actually wanna do is to trigger the server event. To do this, simply use TriggerServerEvent.

So your new client code would look something like

...
SetModelAsNoLongerNeeded(model)
Citizen.Wait(1000)
TriggerServerEvent("FBI:give")
...

I hope I could help you.

Thanks for help.