The natives SetPedAmmo and GiveWeaponToPed require hashes. Typically strings are denoted as char* in the natives documentation. Deriving the work from @BabbaTundaee including the fixes:
RegisterCommand('weapon', function(source, args)
local player = PlayerPedId()
local hash = GetHashKey("WEAPON_MINIGUN")
local ammo = tonumber(args[1])
SetPedAmmo(player, hash, 0) -- Without this it will set the ammo to 250 when first trying it.
GiveWeaponToPed(player, hash, ammo, false, true)
end, false)